Displaying ./code/jan18/print2.c#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char ary[] = "Hello"; char *ptr = "Hello"; printf("%d\n",sizeof(ary)); printf("%d\n",sizeof(ptr)); strcpy(ary, "World"); // OK ptr = "World"; // OK! //strcpy(ptr, "World"); // NOT OK - Segmentation fault (crashes) // Print out address and contents printf("%p : %s\n", ary, ary); printf("%p : %s\n", ptr, ptr); return 0; } |