0

I am try to use an ifstream with the while loop to get each value. However, when I try it, nothing happens. Why?

std::string line;
std::getline(cin, line);
std::ifstream stream(line);
while(stream){
    std::cout << stream.get();
}
2
  • 2
    Wait, do you want to extract values from line or from a file whose name is in line?
    – Medinoc
    Dec 17, 2013 at 16:47
  • @Medinoc - From line itself Dec 17, 2013 at 16:47

1 Answer 1

5

You must use an istringstream, not an ifstream.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.