Hello, I still need some help with this.
When I open the file for writing in ASCII, it writes fine. Then I close it
and reopen it like so:
in.open(filename, ios_base::binary | ios_base:ate), and then I write my
data. When I open the file in notepad, the contents have become all
gibberish, like it's a binary file. But what I'm trying to do is something
like some Linux installation scripts. There is a text area which is human
readable, then it's followed by the binary area. The presumably the text
readable area is parsed by the shell and the binary area is executed. While
that's not what I'm trying to do, I am trying to write and read some raw
data, while being able to parse information about that data in raw text...
Any insights would be appreciated. Thanks in advance.
Smith
"ES Kim" <es***@svd.co.kr> wrote in message
news:bg**********@news1.kornet.net...
"Greg P." <no@spam.sam> wrote in message
news:fT****************@newsread3.news.pas.earthli nk.net... "john smith" <as**@asdf123asdf.net> wrote in message
news:bg***********@news.eecs.umich.edu... Hi, I have a file format that is going to contain some parts in ascii,
and some parts with raw binary data. Should I open this file with
ios::bin or no?
The only difference between text and binary reads are the lack of \r\n
reads for binary. binary reads consider the characters, which mean end of line
for text, potential values themselves. I would suggest opening the file in
binary mode (for most of your file-related coding).
--
Regards,
Greg P.
Golden Rule of Open Source Programming:
"Don't whine about something unless you plan to implement it yourself"
In addition, if you read a binary file in text mode, your program may
quit reading prematurely since it cannot detect the correct EOF position.
--
ES Kim