C - Pointers - Discussion

You Are Here :: Home > C > Pointers - Discussion

 



Q.

What will be output of following c program?

#include
int main(){
int *ptr;
printf("%u\n",ptr);
printf("%d",*ptr);
return 0;
}

A. 2 B. 4
C. 6 D. Any address (Garbage value)

Answer: Option D
Explaination:

Here ptr is wild pointer because it has not been initialized.There is difference between the NULL pointer and wild pointer. Null pointer points the base address of segment while wild pointer doesn't point any specific memory location.



Discussion

Your Comments Goes here...
NameDiscussion