Demo code for char pointer in c:
What will be the output of below C program?
*p = malloc(10);
compile time error
run time crash or may be some garbage value.
char *p; //p is a pointer, which has garbage value now since it is a local variable.
*p = malloc(10); //*p means value at that garbage address
we are allocating some memory, and that address we are
trying to place in some unknown garbage location.
so it may either prints garbage or may crash.
strcpy(p,"skill"); //garbage or crash.
Back To Top