- 1
How can print all my text even when I input a text with space within.
In my code, I realised if I input a two or more words with spaces in between, the compiler ignores the postceeding ones and only outputs the first word. https://code.sololearn.com/cHvVb65Tqv6Z/?ref=app
5 odpowiedzi
0
You have to use getline()
0
As in
cin << getline(var)
Or
0
No, getline is function, you must pass parameters to it.
cin.getline(string, streamsize, separator);
For example
#include <iostream>
using namespace std;
int main()
{
char str[256];
cout << "Enter four sentence: " << endl;
cin.getline(str, 256, ';'));
cout << str;
cin.getline(str, 256, ';'));
cout << str;
}
- 1
Return the code and
replace + with <<
But if you want to use "getline" use std::getline(cin, f);