D
DeveloperDave
Hi,
I am having trouble constructing a vector using some istream_iterators
and a file.....
I have written some code that opens a file and creates a few
istream_iterators.
i.e.
std::fstream file(filename.c_str(), (ios_base::in |
ios_base::binary));
istream_iterator<unsigned char>pos = istream_iterator<unsigned
char>(file);
istream_iterator<unsigned char>start = pos;
istream_iterator<unsigned char>end;
I increment the 'pos' iterator, to iterate through the file. At a
certian point I update 'end' to be equal to 'pos'.
I can print out the values that 'start' and 'end' both reference and
see they are the bytes from the file that I would expect, but when I
try to create a vector, it is always empty e.g.
vector<unsigned char>myVector(start, end);
myVector.size() always returns 0.
Am I using the istream_iterator in the wrong way?
Thanks
I am having trouble constructing a vector using some istream_iterators
and a file.....
I have written some code that opens a file and creates a few
istream_iterators.
i.e.
std::fstream file(filename.c_str(), (ios_base::in |
ios_base::binary));
istream_iterator<unsigned char>pos = istream_iterator<unsigned
char>(file);
istream_iterator<unsigned char>start = pos;
istream_iterator<unsigned char>end;
I increment the 'pos' iterator, to iterate through the file. At a
certian point I update 'end' to be equal to 'pos'.
I can print out the values that 'start' and 'end' both reference and
see they are the bytes from the file that I would expect, but when I
try to create a vector, it is always empty e.g.
vector<unsigned char>myVector(start, end);
myVector.size() always returns 0.
Am I using the istream_iterator in the wrong way?
Thanks