getting many cin on same line

How would I get many cin on the same line?

like
cin >> something1 cin >> something 2 cin >> something 3

on the screen I would want the user to input like
1 1 1


1
2
3
4
5
6
7
int something1, something2, something3;

std::cin >> something1 >> something2 >> something3;

// if you are
// using namespace std;
// you can drop the std:: at the beginning of std::cin 

There are two separate issues here. One is how you write the code. The other is how the user types the input.

For example you could do this:
1
2
3
4
int a, b, c;
cin >> a;
cin >> b;
cin >> c;

The user may enter the data like this:
1
2
3

or
1 2 3

Alternatively you could put:
1
2
int a, b, c;
cin >> a >> b >> c;

and the user may again respond with either:
1
2
3

or
1 2 3
That's because the >> extraction operator normally ignores whitespace, including space, tab and newline characters.
Topic archived. No new replies allowed.