Created
November 22, 2016 02:57
-
-
Save hungtatai/49954ac321244a362bf56544def4a6a9 to your computer and use it in GitHub Desktop.
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> | |
/* | |
如果要在 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