>Hello All,
>I have an app that needs to fopen an ascii file,
>fgets() pulls out the first string.
>I manipulate the data here and then;
>I need to overwrite the line with the new info.
>All this inside a DO while Not feof() loop;
>
>I am not using fputs() to write the line becuase various
>sources of these ascii files may have different carriage returns so I have determined before hand what the return is and store it in a variable. THis way I can =fwrite(maniupateed data + variable)
>
>My problem is I am not successfully moving down with the file
>pointer thus never gettting to FEOF().
>
>I know the length of each record and I also have a counter as I go down the file. SO, I could do an fseek() to the top of the fiel and then move down by string length * the counter.
>
>How do I do this?
>Thanks,
>Sandy
Always remember where your file pointer was before you read the last line. So:
lnLastPos=Fseek(gfh, 0,1) zero bytes offset, from current position
yourString=Fgets(gfh)
[ crunch & munch the data ]
=fseek(gfh, lnLastPos,0) go back to where you were (exact position offset, from start of file)
=fwrite(gfh, YourNewString)
Your new string should be padded with some blanks to the length of the string you got first, and surely not longer than it.