char *s = "Hello world";
writes "Hello world" in the read-only portion of memory, and s
points to that location.
You can no longer write anything else to this memory area.
int main(){
char *s = "Hello World";
s[0] = "h"; // Trying to write read-only. Error!
printf("%s", s);
}
chars[] = "Hello world";
places "Hello world" in the read-only area of memory and copies this string to the stack.
The stack area is easier to modify than the former because it is a usable part.
int main(){
char s[] = "Hello World";
s[0] = "h"; // possible
printf("%s", s);
}
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.