你能解釋一下下面的代碼,勘定指針,地址運營商和取消引用指針用C
int main() {
int value = 2;
int *ptrWithAmpersand = &value;
int *ptrWithoutAmpersand = value;
//printf("%d", *ptrWithoutAmpersand); 1) Why Runtime error.
printf("Pointer with & --> %d\n", *ptrWithAmpersand);
printf("Pointer withOUT & and * --> %d\n", ptrWithoutAmpersand); //2) Why this works??!!
getch();
}
代碼
- 爲什麼運行時錯誤作爲評論?
- 爲什麼這項作品?
輸出是
Pointer with & --> 2
Pointer withOUT & and * --> 2
這是一個非常詳細的解釋。幫助我很多!謝謝! – user859385