“取消引用”指針是什么意思?請(qǐng)舉例說(shuō)明。
3 回答

回首憶惘然
TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊
int a = 10;int* ptr = &a;printf("%d", *ptr); // With *ptr I'm dereferencing the pointer. // Which means, I am asking the value pointed at by the pointer. // ptr is pointing to the location in memory of the variable a. // In a's location, we have 10. So, dereferencing gives this value. // Since we have indirect control over a's location, we can modify its content using the pointer. This is an indirect way to access a. *ptr = 20; // Now a's content is no longer 10, and has been modified to 20.

汪汪一只貓
TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
int a=4 ;int *pA = &a ;printf( "The REFERENCE/call number for the variable `a` is %p\n", pA ) ;// The * causes pA to DEREFERENCE... `a` via "callnumber" `pA`.printf( "%d\n", *pA ) ; // prints 4..
- 3 回答
- 0 關(guān)注
- 1602 瀏覽
添加回答
舉報(bào)
0/150
提交
取消