c++ - How to store a complete sentence with white spaces in a string in cpp? -


this question has answer here:

i want store "what wrong you?" in string str in cpp when run code stores "what" in ·str·.

how can store complete sentence in string.

#include<iostream> #include<string.h> using namespace std; int main() {     string str;     cin>>str;     cout<<str; }  

input:

what wrong you? 

output:

what 

was answered. here solution:

std::string str;  std::getline( std::cin, str); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -