+ 3

Constant Pointer Error in C

//ok int a=5; int* const ptr=&a; printf("%d ", *ptr); //Error int* const ptr2; int b=56; ptr2= &b; printf("%d ", *ptr2); Why the second part produces error as the output?

30th Jul 2021, 9:44 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
1 Réponse
+ 3
ptr2 is an undefined constant that cannot be changed. Debug: int* ptr2; int b = 56; ptr2 = &b; printf(%d", *ptr2);
30th Jul 2021, 9:56 AM
Solo
Solo - avatar