When we declare
"a" should be a pointer to an integer with nothing to point to (NULL).Code:int *a = NULL;
and I think this statement is acceptableCode:int b = 1;
because now "a" is a pointer to an integer that point to value of "b"Code:a = &b;
But,... What's happen here?
I think this is illegal ( undefined behaviour, maybe? ) since "a" is pointing to nothingCode:int c = 2; *a = b;
and there is no memory allocated for its value.
Or 0 (NULL) has its own value?
Thanks in advance.Code:#include "stdio.h" int main( int argc, char *argv[] ) { int *a = NULL; printf( "%d\n", a ); int b = 1; a = &b; printf( "%d\n", *a ); // >> 1 int c = 2; *a = c; printf( "%d\n", *a ); // >> 2 ?? }