I am just trying to explore c and i was wonder what is reason behind ... segmentation fault..
but second function is workiing .. can someone explain me reason
void myfunc1(char *t)
{
t = t+1;
t = 'l'; //it gives segmentation fault ? why
}
void myfunc2(char *s)
{
s[2] = 'l'; /* it works fine */
}
int main()
{
char * x ="vipin";
char y[] = "vipin";
myfunc1(x);
myfunc2(y);
printf("%s \n",x);
printf("%s \n",y);
return 0;
}