-
stream command....
hi, my question is really simple. Im working with streams and i dont know the "end of file" command for c++ (i dont even know if there is such a thing) any help would be appreciated ;D
oh and also, lemme know if this thinking is correct:
i wanna do something like
(pseudocode)
while(!eof)
read file to populate an Event vector (consisting of a string and a number)
ive already populated a vector with a finite capacity but i wanna be able to "push_back" it to fill it with the entire content of the file.
thanks :D
-
Code:
if (!infile.is_open())
return -1;
while (infile.peek()!=EOF)
{
//read
}
-
ty ty will try it when i get home ;D
-
Oh I just noticed I left that if(!infile.open()) there...it's good to check for that before you try to read, but make sure returning -1 works for wherever you put it in your code :D