Skip to content

Instantly share code, notes, and snippets.

@AnaTofuZ
Created February 18, 2019 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnaTofuZ/e11c9182dcce2ad35148701301a7328b to your computer and use it in GitHub Desktop.
Save AnaTofuZ/e11c9182dcce2ad35148701301a7328b to your computer and use it in GitHub Desktop.
extern int printf(const char *,...);
int *f() {
int i = 6;
printf("in f %d\n", i);
printf("in f %p\n", &i);
return &i;
}
int *g() {
int i = 9;
printf("in f %d\n", i);
printf("in f %p\n", &i);
return &i;
}
int main(){
int *i = f();
printf("in main %d\n", *i);
printf("in main %p\n", i);
i = g();
printf("in main %d\n", *i); //ここで上書きされているはず
printf("in main %p\n", i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment