Possible Duplicate:
How do I iterate over cin line by line in C++?
I need to read all lines from a file:
std::ifstream file("...");
std::vector<std::string> svec(
(std::istream_iterator<std::string>(file)),
(std::istream_iterator<std::string>()),
);
but it is read as words.
I believe the issue is that the input methods for
std::stringwill read until a space character is found, then terminate.Have you tried using
std::getlineinside a loop?Check out the C++ FAQ.