Question about very simple terminal app on Mac OS X

This is a terminal app, and this is the entirety of the program. I noticed if I supply input of something like 12345 and then hit enter in the terminal window, after hitting enter, I see one response line from the program which reads "input recv". However if I enter "1 2 3 4 5" as an input string I get 5 lines of "input recv" sequentially output in the terminal window.

What exactly is happening? I'm a bit confused on this.

Thanks in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #include <iostream>
#include <string>

using namespace std;

int main(int argc, const char * argv[])
{

    bool run = true;
    // insert code here...
    std::cout << "Hello, World!\n";

    string curLine = string();
    while( run == true )
    {
        
        std::cin >> curLine;
        std::cout << "input recv\n";
    }
    
    return 0;
}
http://www.cplusplus.com/reference/string/string/operator%3E%3E/
Notice that the istream extraction operations use whitespaces as separators; Therefore, this operation will only extract what can be considered a word from the stream. To extract entire lines of text, see the string overload of global function getline.

Elsewhere:
Extracts characters from is and stores them ..., stopping as soon as ... a whitespace character is encountered
Internally, the function accesses the input sequence by first constructing a sentry object (with noskipws set to false).
noskipws==false means same as skipws==true
skipws ... leading whitespaces are discarded before formatted input operations.
Topic archived. No new replies allowed.