Hi
I am processing soem text files in C using dyanmic memory allocation where I need to compare 2 files with 100000 records.
the code is
FILE *f;
char s[10],s1[10];
char a[LIMIT][10],a1[LIMIT][10];//LIMIT = 100000
int x=0,y,i=0,j=0,k,i_sec=0,j_sec=0,k_sec,k_comp,l_com p,q;
//master.txt is the masterfile.Ex: G11
f=(FILE *)malloc(100000);
f=fopen("C:/WIN95/Desktop/master.txt","r");
if (!f)
return 1;
while ((fgets(s,11,f)!= NULL) && (i < LIMIT)) //fgets reads a string from the file
{
strcpy(a[i],s);
//printf("% d ---- %s\n",i,a[i]);
++i;
}
k=i;
//printf("k= %d",k);
free(f);
fclose(f);
But I get a memeory error; perhaps exceeding the heap allocation.
I will be very thankful if you can help me here.