In this program I have char variable a
, b
is a pointer to a
and c
is a pointer to b
. While *a=b
, *c
not equal to b
. I don't understand why ,Can anyone explain?
Another thing I don't understand I that if I change variable from char
to int
, dereference c
result b
value. *c
equal to b
.But if variable is char
type, it does not.
#include<stdio.h>
#include<string.h>
int main()
{
char a = "a" ;
char *b;
b = &a;
printf("%d\n", b);
printf("%d\n\n", &a);
printf("Deference b* hold value: %d\n", *b);
printf("a hold value: %d\n\n", a);
char *c;
c = &b;
printf("%d\n", c);
printf("%d\n\n", &b);
printf("Deference *c hold value: %d\n", *c);
printf("b hold value: %d\n\n", b);// why *c not equal b
return 0;
}