I was having a lecture about pointers and I thought I understood already. Until I tried this simple code that doesn't work. It gives "Segmentation fault: 11".
This is my understanding: in the initialization int *a, I set a to be an address pointing to an integer. Then I scan an integer and store it on the address of a. Finally I print the integer stored in the address of a. So, what went wrong?Code:#include<stdio.h>
int main()
{
int *a;
scanf("%d", a);
printf("%d", *a);
return 0;
}