a question of cin

How can i input a string with blank by cin?

like;
string s;
cin >> s;

when i input "Hello world", s just get "Hello"

thanks your help

cin >> cuts it off as soon as it gets a whitespace. To solve this, use getline() to get a string.

getline(std::cin, string_variable);
can you try cin.getline()

Edit: Late
Last edited on
Topic archived. No new replies allowed.