A
ahmadcorp
Hi,
This should be a simple problem, but I can't seem to figure it out.
Maybe someone can help?
I have a file containing data each line has about 6 entries (numbers)
space delimited and each line has a new line character at the end of
the line. I'd like to read the file in one pass, so I am trying to use
std::istreambuf_iterator as follows (where inputFile is an ifstream):
std::vector<std::string>
data( std::istreambuf_iterator<std::string>(inputFile) ,
std::istreambuf_iterator<std::string>())
The problem I am facing is that I cannot then iterate over vector of
strings in the usual manner;
std::vector<std::string>::iterator(data.begin());
OR
std::vector<std::string>::iterator(data->begin());
I keep getting compilation errors:
error: request for member `begin' in `data', which is of non-aggregate
I must be missing something completely. I'd greatly appreciate some
help. Thanks.
This should be a simple problem, but I can't seem to figure it out.
Maybe someone can help?
I have a file containing data each line has about 6 entries (numbers)
space delimited and each line has a new line character at the end of
the line. I'd like to read the file in one pass, so I am trying to use
std::istreambuf_iterator as follows (where inputFile is an ifstream):
std::vector<std::string>
data( std::istreambuf_iterator<std::string>(inputFile) ,
std::istreambuf_iterator<std::string>())
The problem I am facing is that I cannot then iterate over vector of
strings in the usual manner;
std::vector<std::string>::iterator(data.begin());
OR
std::vector<std::string>::iterator(data->begin());
I keep getting compilation errors:
error: request for member `begin' in `data', which is of non-aggregate
type `std::vector said:, std::istreambuf_iterator<std::string, std::char_traits<std::string>
(*)())'
I must be missing something completely. I'd greatly appreciate some
help. Thanks.