T
The Cool Giraffe
Regarding the following code i have a problem.
void read () {
fstream file;
ios:pen_mode opMode = ios::in;
file.open ("some.txt", opMode);
char *ch = new char[1];
vector <char> v;
while (!file.eof ()) {
do {
file.read (ch, 1);
v.push_back (*ch);
}
while ((int)ch[0] != 10 || file.eof ());
}
file.close ();
}
For some reason, one that i don't comprehend, i get through
the inner while-loop three times (as suppsed to) but then, i
get stuck and the computer does not see the end of the file.
Contents of the file are three lines of normal text and then
a double saved binary.
Any thoughts? My guess is that it's perhaps due to that i
didn't open the file binary but does it really matter to
recognizing "the end"? How can i "switch" the openess
of the file?
Yes, the file _IS_ supposed to have a leading few lines of
normal text and then a bunch of binary data. Sad but true...
void read () {
fstream file;
ios:pen_mode opMode = ios::in;
file.open ("some.txt", opMode);
char *ch = new char[1];
vector <char> v;
while (!file.eof ()) {
do {
file.read (ch, 1);
v.push_back (*ch);
}
while ((int)ch[0] != 10 || file.eof ());
}
file.close ();
}
For some reason, one that i don't comprehend, i get through
the inner while-loop three times (as suppsed to) but then, i
get stuck and the computer does not see the end of the file.
Contents of the file are three lines of normal text and then
a double saved binary.
Any thoughts? My guess is that it's perhaps due to that i
didn't open the file binary but does it really matter to
recognizing "the end"? How can i "switch" the openess
of the file?
Yes, the file _IS_ supposed to have a leading few lines of
normal text and then a bunch of binary data. Sad but true...