Created
October 24, 2014 03:31
-
-
Save honux77/c44182cdf8e777dc2d38 to your computer and use it in GitHub Desktop.
address of function and others
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| void foo() {printf("I am foo\n");} | |
| int global = 10; | |
| int main(void) { | |
| int x = 100; | |
| char *literal = "Hello"; //read only, literal[1] = 'h' --> error | |
| char stack[] = "Hello"; //stack | |
| char *heap = (char *) malloc(sizeof(char)* 6); //heap | |
| printf("address of foo = %p\n", foo); | |
| printf("address of main = %p\n", main); | |
| printf("address of literal = %p\n", literal); | |
| printf("address of global = %p\n", &global); | |
| printf("pointer value in stack = %p\n", stack); | |
| printf("address of x = %p\n", &x); | |
| printf("pointer value in heap = %p\n", heap); | |
| return 0; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
== Result (VS2013, win7) ==
address of foo = 002A10F0
address of main = 002A1140
address of literal = 002A5878
address of global = 002A801C
pointer value in stack = 0046F90C
address of x = 0046F928
pointer value in heap = 0083E2B0
계속하려면 아무 키나 누르십시오 . . .