Search and replace string

This program accepts string from user as input.The string to be searched is stored in variable s and the string to be replaced is stored in variable r.Different counters such as i,m,c and j are used whose initial value is 0.The values from character array str and s are compared. If the values match then the counters i and m are incremented.Character array ans stores the resultant string after replacing the searched string. If the value from character array str and s match,then a value from replacement array i.e. r is copied into array ans.This process continous until the string str end i.e. '\0' is reached while parsing every character of the array str.When the string str terminates ,the resultant string after searching and replacement is stored in array ans.

#include < stdio.h >
#include < conio.h > 
void main()
{
	char str[100],s[100],r[100],ans[100];
	int i,j,c,m,k;
	clrscr();
	printf("\nEnter a string \n");
	gets(str);	
	printf("\nEnter a search string \n");
	flushall();
	gets(s);	
	printf("\nEnter a replace string \n");
	flushall();
	gets(r);	
	i = m = c = j = 0;
	while ( str[c] != '\0')
	{
		if ( str[m] == s[i] ) // ...... matching
		{
			i++;
			m++;
		if ( s[i] == '\0') //.....found occ
		{
		//.... copy replace string in ans string .....
		for(k=0; r[k] != '\0';k++,j++)
			ans[j] = r[k];
			i=0;
			c=m;
		}
		}
		else //... mismatch
		{
			ans[j] = str[c];
			j++;
			c++;
			m = c;
			i=0;
		}
	}//while
	ans[j] = '\0';
	printf("\nThe resultant string is\n%s" ,ans);
} // main