+ 1

cin output, difficulty with 'space'

I am currently having trouble with the 'cin' function extracting data from the input stream, where the input by the user contains a space. The input string is then truncated from the first instance of a space. As an example if I would enter a phrase like 'Hello World' when prompted to in the console from 'cin', then when using the function 'cout' the console outputs only the word 'Hello'. How do I go about having the console pull the entirety of a phrase rather than a truncated version of what was entered?

4th Dec 2016, 5:53 PM
Bryan Isles
Bryan Isles - avatar
1 Resposta
+ 6
use cin.getline();
4th Dec 2016, 6:10 PM
HAL8999++;
HAL8999++; - avatar