Skip to content

Instantly share code, notes, and snippets.

@brianhsu
Created March 7, 2016 10:02
Show Gist options
  • Select an option

  • Save brianhsu/0f30faa7634cedff28c6 to your computer and use it in GitHub Desktop.

Select an option

Save brianhsu/0f30faa7634cedff28c6 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void test(int x, void * userdata) {
printf("x.value:%d\n", x);
int * pointer = (int *) userdata; // userdata 指到的記憶體位置
printf("userdata.address:%d\n", pointer);
int value = *pointer; // 取出這個位置實際存放的值
printf("userdata.value:%d\n", value);
}
void main() {
int x = 10;
int y = 20;
test(x, &y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment