Skip to content

Instantly share code, notes, and snippets.

@knjname
Created May 9, 2015 02:58
Show Gist options
  • Save knjname/7c06f59120c27463a9d2 to your computer and use it in GitHub Desktop.
Save knjname/7c06f59120c27463a9d2 to your computer and use it in GitHub Desktop.
An example code described in "21st Century C" that rewrites the value of a const variable.
#include <stdio.h>
int main(void) {
int *a;
const int **b = &a;
const int c = 1;
printf("c = %d\n", c); // c = 1
*b = &c;
*a = 2;
printf("c = %d\n", c); // c = 2
return 0;
}
@knjname
Copy link
Author

knjname commented May 9, 2015

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