Skip to content

Instantly share code, notes, and snippets.

@hungtatai
Created November 22, 2016 02:57
Show Gist options
  • Save hungtatai/49954ac321244a362bf56544def4a6a9 to your computer and use it in GitHub Desktop.
Save hungtatai/49954ac321244a362bf56544def4a6a9 to your computer and use it in GitHub Desktop.
#include <stdio.h>
/*
如果要在 main 用 d ,那跟在 A 用 *a 或在 B 用 b 意思是一樣的
但如果要在 main 用 &d ,那跟在 B 用 &b 意思是不一樣的,切記要用 A 的 a 當做做法
*/
void A (int **a) {
printf("A: *a: %p\n", *a);
printf("A: a: %p\n", a);
}
void B (int *b) {
printf("B: b: %p\n", b);
printf("B: &b: %p\n", &b);
}
int main()
{
int c = 50;
int *d;
d = &c;
printf("*d: %d\n", *d);
printf("d: %p\n", d);
printf("&d: %p\n", &d);
A(&d);
B(d);
return 0;
}
/*
*d: 50
d: 0x7ffcd422114c
&d: 0x7ffcd4221140
A: *a: 0x7ffcd422114c
A: a: 0x7ffcd4221140
B: b: 0x7ffcd422114c
B: &b: 0x7ffcd4221128
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment