Question: Is it possible to modify a string literal in c?
No, it is not possible to modify a string literal in C. String literals are declared using double quotes and are stored in read-only memory, which means that any attempt to modify them will result in undefined behavior. In C, string literals are treated as constant arrays of characters, and any attempt to modify the contents of the array will result in a compile-time error or a segmentation fault at runtime. If you need to modify a string in C, you should use an array of characters instead of a string literal.
Comments
Post a Comment
let's start discussion