Hello.
I'm moving from Visual C++ 6.0 to Visual C++ .NET 2003 and I saw the
changes to the streams. I'm rewriting my code and finished doing it
yesterday.
All seemed to be right, but the file reading.
My old code has lines like the following function call:
(file is a ifstream, var is a WORD, that is a typedef unsigned sort)
here is the line:
file.read(&var, 2)
Well, when this line is executed, the results are not what I'm looking
for: it reads inconsistent (arbitrary?) data. In my old code this line
worked. It is supposed to read 2 bytes from the file and asign them to
the WORD in var.
For this reason, I think that Visual C++ 6.0 and .NET 2003 has some
slight differences for reading in the way I want to read.
Maybe I'm not properly using the function. I mean... maybe I don't
understand well the mechanism in C++ to read BYTES, WORDS, DWORDS
UWORDS, etc.
So I request your help and would be thankful is someboy teach me about
reading using standar C++ streams in this .NET 2003.
Thank you very much.
Igor Tandetnik - 26 Jul 2004 23:55 GMT
"Jos? Manuel (JMN CandyBeat)" <jmn@superjmn.com> wrote in message
news:uKPvMclcEHA.3044@TK2MSFTNGP10.phx.gbl
> My old code has lines like the following function call:
>
[quoted text clipped - 5 lines]
> Well, when this line is executed, the results are not what I'm looking
> for: it reads inconsistent (arbitrary?) data.
Are you opening the file in text mode (without ios::binary flag) by any
chance? What you see may be caused by CRLF to \n translation.

Signature
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"José Manuel (JMN CandyBeat)" - 27 Jul 2004 15:35 GMT
>>My old code has lines like the following function call:
>>
[quoted text clipped - 8 lines]
> Are you opening the file in text mode (without ios::binary flag) by any
> chance? What you see may be caused by CRLF to \n translation.
Whops! I solved the problem, it's because I was reading the wrong
position in the file and that explains why the reads was incoherent!
(By the way, I was using ios::binary | ios::in)
Thank you!!