Skip to content

Instantly share code, notes, and snippets.

@soltys
Created June 18, 2011 16:23
Show Gist options
  • Save soltys/1033243 to your computer and use it in GitHub Desktop.
Save soltys/1033243 to your computer and use it in GitHub Desktop.
int main(void)
{
char *s = "hello world";
*s = 'H';
}
@md2perpe
Copy link

That code will probably crash (and it does when I test it). The string is placed in read-only memory, so when you try to change it... CRASH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment