I know that string literals are stored in read-only memory ,so you can't update them. But what's wrong with strlen() function.it works if i initialize char *s within the program. i.e
char *s="hey";
length=strlen(s);
printf("%d\n",length);// this works
and doesn't when taking string from user
char *s;
int length;
scanf("%s",s);
length=strlen(s);
printf("%d\n",length); //this doesn't. gives segmentation fault