Hello
I am trying to find a string in a text file.
The program is working fine when I search small text files.
But the turbo C compiler is just disappearing when the text file to be searched is large.
Why is this happening?
How can I fix it?
Code:
#include <stdio.h>
#include <string.h>
int main()
{
int ch,i=0,j=0,k;
char store[300][100];
char one_file[] = "one.txt";
char two_list[] = "two.txt";
FILE *one,*two;
clrscr();
one = fopen(one_file,"r");
two = fopen(two_list, "w");
while((ch=getc(one))!=EOF)
{
if(ch=='s')
{
if((ch=getc(one))=='r')
if((ch=getc(one))=='c')
if((ch=getc(one))=='\=')
if((ch=getc(one))=='\"')
{
j=0;
while((ch=getc(one))!='\"')
{
store[i][j]=ch;
fprintf(two, "%c",ch);
j++;
}
store[i][j]='\0';
fputc('\n',two);
i++;
}
}
}
for(k=0;k<i;k++)
printf("string[%d]=%s\n",k,store[k]);
fclose(one);
fclose(two);
return(0);
}