Here is the code:
string fname = "/home/jack/example.csv";
ifstream csvin(fname.c_str());
if (csvin.eof()) {
do_something;
}
My question is: In what case eof()
returns true. I have the following options:
- File does not exist.
- File is empty.
- File either does not exist or it is empty.
Unfortunately documentation does not help since I do not know eofbit error state flag
means. I also do not understand what End-of-File is reached in the sequence associated with the stream
mean. I assume that c_str() returns some iterator and if it is already used by something it might already reach its end. However, I am interested in simple case when result of c_str()
is fresh, what will it return if file does not exist and what will it return if file is empty?
EDITED
I just would like to know what the above given code returns in two cases:
- File does not exist.
- File is empty.