View Single Post
  #1 (permalink)  
Old November 1st, 2007, 11:39 PM
watashi watashi is offline
Authorized User
 
Join Date: Jul 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem while file read

Hello,
 I think it is very silly, but i couldnt trace out the problem.
 I am trying to read 3 lines from file using fgets, then using fseek i m placing the pointer back one line.
 But after that when i do fgets i m not getting the complete line.Instead first 3 charecters are missing.

My code looks like

    for(i = 0; i < 3; i++)
        fgets(strBuf,500,fpInFileNext);

    cnt = strlen(strBuf);
    fseek(fpInFileNext,-(cnt),SEEK_CUR);
    fgets(strBuf,500,fpInFileNext); // now strBuf contains line with
                                         3 missing charecters.

What may be the problem?????????

Cheers,
Reply With Quote