The following code is made:
#include <string>
#include <iostream>
using namespace std;
int main() {
string s;
while(true) {
cin >> s;
cout << "type : " << s << endl;
}
}
The output of the console is:
INPUT: usa americ england gana
OUTPUT:
type : usa
type : americ
type : england
type : gana
INPUT: hello world
OUTPUT:
type : hello
type : world
Whenever I type "usa americ englend gana" and then enter, it displays each string input via cin in the while block.
Is there any reason for this? How is the "stream buffered"?
How could I make it so that whenever multiple strings are input via cin, there is no separation made by whitespaces? Is there any particular function or answer to this problem?