0

How to input a sentence with spaces?

#include <iostream> #include <string> using namespace std; int main() { cout <<"Enter a sentence:"; string sentence=""; cin >>sentence; cout <<sentence; return 0; } Input: C++ is best language ever Output: C++

3rd Jul 2016, 11:47 AM
[No Name]
3 Respostas
+ 1
you can us getchar_unlocked(variable name)it is the fastest input taking function....
4th Jul 2016, 3:48 AM
santosh kumar
santosh kumar - avatar
0
you can use getline. it is the function that requires two parameters: string n; getline (cin, n); now that you enter a sentence it will be assigned to ur variable called n
3rd Jul 2016, 12:00 PM
Sardor
Sardor - avatar
0
its 1 word because cin function will stop read input until the user input a blank char such as space,tab, or enter
3rd Jul 2016, 3:27 PM
ramabena
ramabena - avatar