Created
February 18, 2019 04:08
-
-
Save AnaTofuZ/e11c9182dcce2ad35148701301a7328b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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