first line of input is invisible for while(cin >>)

Jan 25, 2019 at 3:32am
Hello, I've just started working out of Programming, Principles and Practice Using C++, and I came upon a part in which I don't understand the behavior.

The book says to make a while loop that, in every loop, reads two ints and prints them. I have the code functional, however there is an oddity in that, the first line of input can't be seen. I say seen, not accepted. I can still type the input, press enter, and it accepts it, and from there, I can see the input.
1
2
3
4
5
6
7
8
9
10
11
 #include "std_lib_facilities.h"

int main() {
    
    int temp_num_1;
    int temp_num_2;
    while(cin >> temp_num_1 >> temp_num_2)
    {
        cout << "\nYou've entered values " << temp_num_1 << " and " << temp_num_2 << ".\n";
    }
}


Why does it behave this way? I thought perhaps it was just an oddity with the provided header and so used the standard library, but it gave the same results.

I'm using Xcode on macOS Mojave in case that is important.
Last edited on Jan 25, 2019 at 4:07am
Jan 25, 2019 at 4:02am
Works fine for me. That's your terminal emulator doing that, not your code.
Topic archived. No new replies allowed.