Let's compile some real simple code and see why whitespace is needed to differentiate inputs:
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
int main()
{
int a { };
std::cin >> a;
int b { };
std::cin >> b;
std::cout << a << ", " << b << '\n';
}
|
When run enter each value separate, followed by hitting the return key (the return key enters a newline into the input stream....whitespace):
Separate the values by a space, then enter:
A space is whitespace
tab and enter:
tab is whitespace
Only a comma, no other whitespace, and enter:
Hmmmm, maybe just a comma alone isn't a good way to separate out multiple inputs.
No whitespace, and just hit enter:
The program only received one value, 1234, and is waiting for another to be entered.