From: Ganga Sridhar on
Platform : .NET VisualStudio2005 , VC++, Windows XP

Hello

In my VC++ program I am reading a file in text mode using CStdioFile.
I am trying to read the file character by character until I encounter the token (Decimal 10 / 0xa)
CStdiofile and Seek(nBytes,CFile::current);
where nByte = 1

Now when I try to read the next character after 0xa, I find that the offset has moved 1 byte extra.
For eg.
BG*test*test2*12345*1326*9150
GS*mytest*test4

Before GS the file contains 0xa (when viewed in hex editor)
Now when I try to read the next character after 0xa , I get 'S' instead of 'G'

Is there some know bug regarding this?

Any pointers would be of great help.

Thanks and Regards
Ganga
From: Igor Tandetnik on
"Ganga Sridhar" <gangasridhar(a)abosoftware.com> wrote in message
news:uY1ds3MsIHA.484(a)TK2MSFTNGP04.phx.gbl
> In my VC++ program I am reading a file in text mode using CStdioFile.
> I am trying to read the file character by character until I encounter
> the token (Decimal 10 / 0xa)
> CStdiofile and Seek(nBytes,CFile::current);
> where nByte = 1
>
> Now when I try to read the next character after 0xa, I find that the
> offset has moved 1 byte extra.
> For eg.
> BG*test*test2*12345*1326*9150
> GS*mytest*test4
>
> Before GS the file contains 0xa (when viewed in hex editor)
> Now when I try to read the next character after 0xa , I get 'S'
> instead of 'G'

I don't quite follow. After you've read the end-of-line character, the
file pointer is positioned at G. You seek by one byte, so the file
pointer is now positioned at S. Why again do you expect to read G? Why
do you feel you need to seek in the first place?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: Ben Voigt [C++ MVP] on
Igor Tandetnik wrote:
> "Ganga Sridhar" <gangasridhar(a)abosoftware.com> wrote in message
> news:uY1ds3MsIHA.484(a)TK2MSFTNGP04.phx.gbl
>> In my VC++ program I am reading a file in text mode using CStdioFile.
>> I am trying to read the file character by character until I encounter
>> the token (Decimal 10 / 0xa)
>> CStdiofile and Seek(nBytes,CFile::current);
>> where nByte = 1
>>
>> Now when I try to read the next character after 0xa, I find that the
>> offset has moved 1 byte extra.
>> For eg.
>> BG*test*test2*12345*1326*9150
>> GS*mytest*test4
>>
>> Before GS the file contains 0xa (when viewed in hex editor)
>> Now when I try to read the next character after 0xa , I get 'S'
>> instead of 'G'
>
> I don't quite follow. After you've read the end-of-line character, the
> file pointer is positioned at G. You seek by one byte, so the file
> pointer is now positioned at S. Why again do you expect to read G? Why
> do you feel you need to seek in the first place?

Are you trying to skip over the LF byte of the CR+LF pair? If you are in
text mode then this is skipped automatically.