+ 8

why does the string not equal to the inputted string value?

basic overview of my code: cin>>userinput // i input "hi there" cout<<userinput //outputs hi, not hi there?

26th Apr 2017, 2:29 AM
DeleteThisAccount
3 Answers
+ 8
because cin reads the string until it reads a space use getline(cin, userinput) to read the whole line
26th Apr 2017, 2:40 AM
chris
chris - avatar
+ 5
cin ends at whitespace you will need to use getline instead.
26th Apr 2017, 2:38 AM
jay
jay - avatar
+ 5
getline(cin,strUserInput); cout << strUserInput;
26th Apr 2017, 2:41 AM
jay
jay - avatar