Hi All,
I have written one small program where i m reading one file till the cursor position 200000 and writing into anther file.But its reading only first record and came out.i mean while loop is running once and if loop condition is SEEK_CUR reached 200000 in first time.below is my program.
Code:
#include<stdio.h>
#define MAX_DATA_LEN 999999
main()
{
FILE *fp,*fp1;
char lineOfText[400000];
if (( fp = fopen("test.dat", "r")) == NULL )
{
printf("\n Error in opening the Source file ");
exit(1);
}
if ((fp1 = fopen("ED_ALS_LOAN_split.dat","a")) == (FILE *) NULL)
{
printf("\n Error in opening the first splited file");
exit(1);
}
while(fgets(lineOfText, MAX_DATA_LEN, fp ) != NULL)
{
if ( (fseek(fp,200000,SEEK_CUR )) != NULL )
{
printf("file curosr reached at %d position\n",end_pos);
exit(1);
}
else
{
printf("\n lineOfText=%s",lineOfText);
fputs(lineOfText,fp1);
}
printf("\n Inside the while loop");
}
fclose(fp1);
fclose(fp);
}
above i have marked the red, i thnk the loop is having some problem,pls help me to sort out.
THanks
Anwar