I'm having a problem with c string, I want to keep address of original string aside and manipulate string using another c pointer, but it will give an segmentation fault when try to print that string using original or secondary pointer, however declaring string as character array does not present such fault. I don't to use array as well as I don't want to lose original address. Please point the problem.
/* segmentation fault when run */
char *string = "Hello World";
char *nick = string;
while(*nick)
*nick++ = '0';
printf("%s\n", string);
/* display 000000000000 when run (wished result)*/
char array[] = "Hello World";
char *nick = array;
while(*nick)
*nick++ = '0';
printf("%s\n", array);