C Programming: Modifying String Literals - Segmentation Fault
This code will result in a segmentation fault or undefined behavior.
The variable 'p' is a pointer to a string literal 'hello'. String literals are stored in read-only memory, which means that attempting to modify them will result in a segmentation fault or undefined behavior.
In this code, the statement 'p[0] = 'a'' attempts to modify the first character of the string literal, which is not allowed.
Therefore, the program may crash or produce unexpected results when executed.
原文地址: https://www.cveoy.top/t/topic/nyqY 著作权归作者所有。请勿转载和采集!