It's best not to use EOF .
You probably don't have to read character by character also. Look into the >> operator and the getline() method of istream (implemented by ifstream).
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
Do you mean, How to read file in binary mode?
If, so you may do something like this:
file->read(reinterpret_cast<char *>(this), sizeof(Channe1));
Correct me if i did something wrong
,,,
Kimo :P
kim00000
Junior Poster in Training
93 posts since Oct 2009
Reputation Points: 12
Solved Threads: 11
It's best not to use EOF .
EOF is fine. It's best not to us .eof() -- a big difference. :icon_wink:
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
You've done it again WaltP! That's my bad. Well, Dave's thread's a good read anyway. :)
I still maintain that reading in character by character (and seemingly throwing them away once a new one is read) is probably not the best approach.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
if you use std::strings, then yes:
std::string buffer;
ifstream in("c:/.........");
std::getline(in, buffer);
std::cout << "Read :" << buffer;
But if you insist on using char-arrays, then you need to input the number of chars to read. This is to prevent you from running out of your arays bound without even noticing.
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403