char *strip_postfix(char *str1, char *str2)
{
int i;
for(i=0; str2[i] != '\0'; i++)
{
if(str1[i] != str2[i])
{
str1[i] = '\0';
break;
}
}
return str3;
}
This code, is giving segmentation fault error at line str1[i] = '\0' during run time..... I think there is some memory allocation issue,, as while I create a new variable and copy the contents there, and then return that new variable, everything works fine.... Please let me know what's the issue in this.