Array of pointers problem
i need help in a program to take two strings str1, str2. define an array of pointer str. if str1 appears in str, replace all those with str2. i made this program but its crashing. pls tell why? #include<stdio.h> int main() { char *str[5] = { "one", "two", "three", "four", "five", }; char str1[100],str2[100]; printf("Enter to strings: "); gets(str1); gets(str2); int i,j,l,m; for(i=0;i<5;i++) for(j=0;str[i][j]!='\0';j++) { int a=0; for(l=j,m=0;str1[m]!='\0';l++,m++) { if(str[i][l]!=str1[m]) { a = 1; break; } } if(a==0) { for(l=j,m=0;str2[m]!='\0';l++,m++) str[i][l]=str2[m]; } } printf("New str:\n"); for(i=0;i<5;i++) printf("%s\n",str[i]); return 0; }