We know that int *p;
means declaring a pointer p
to int data and int a,b;
means declaring two int variables.
If we consider int *
as a data type which means the pointer to int data, then the int*a,b;
would means that declaring two pointers.
But it is not consistent with my code result.
This is my code
#include <stdio.h>
int main(void)
{
int i=10;
int * a,b;
a=&i;
b=&i;
printf("%d\n",*a);
printf("%d",*b);
return 0;
}
The code failed to compile.I removed the *
in front of the b
and then the code ran successfully.
#include <stdio.h>
int main(void)
{
int i=10;
int * a,b;
a=&i;
b=&i;
printf("%d\n",*a);
printf("%d",b);
return 0;
}
This seemed that b
was not the pointer and it was the int variable.
Since we couldn't see the *
as a notation which is independent of p
,does this mean that int* p
doesn't equal to int *p
although the result are same?