I am a new learner for c. And I met with this ERROR.
int *p;
*p=6;//ERROR
int a=6;
*p=a;//Right
Could you please explain this situation? Thank you very much!
I am a new learner for c. And I met with this ERROR.
int *p;
*p=6;//ERROR
int a=6;
*p=a;//Right
Could you please explain this situation? Thank you very much!
Both example are incorrect.
Before you can dereference a pointer, you need to make it point someplace. For example:
int *p;
int a;
p = &a;
a = 5;
printf("*p=%d\n", *p); // prints *p=5
a = 6;
printf("*p=%d\n", *p); // prints *p=6