K
Karl Heinz Buchegger
glen_stark said:Hi.
I have code for reading and writing gds files that I have inherited from
a company and need to make standards compliant. Unfortunately the code
is heavily dependant on the win api. I think I can get around
everything but one stumbling point I would like some advice on.
The win api uses an unsigned char array for writing binary data to and
from the gds file. Now, one reason I want standards compliant code is
to be able to run my code on a variety of different machines, so I can't
count on the same representation of char (as signed or unsigned).
The std iostream however, uses plain char for binary output (please let
me know if I am missing anything). I need to be able to read and write
these files from any machine, and be able to read the files written by
users of the company code.
So what I need to do is make sure that char array I am passing to
std::write contains an unsigned char binary representation.
stick with unsigned char and cast the pointer you give
to read() and write() to char*. read() and write() will do
nothing to the chars if you open the file in binary mode.