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++
3 Réponses
+ 1
you can us getchar_unlocked(variable name)it is the fastest input taking function....
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
0
its 1 word because cin function will stop read input until the user input a blank char such as space,tab, or enter