Skip to content

Instantly share code, notes, and snippets.

@honux77
Created October 24, 2014 03:31
Show Gist options
  • Select an option

  • Save honux77/c44182cdf8e777dc2d38 to your computer and use it in GitHub Desktop.

Select an option

Save honux77/c44182cdf8e777dc2d38 to your computer and use it in GitHub Desktop.
address of function and others
#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;
}
@honux77
Copy link
Copy Markdown
Author

honux77 commented Oct 24, 2014

== 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
계속하려면 아무 키나 누르십시오 . . .

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