Using while loop, Help get the output to stay all on the same line

Based on the code I've written below, after debugging in vs 2010, It won't allow me to put the input of cin on the same line as the output before it.

Any help would be greatly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;


int main ()

{
	int a = 101;
	

	
while (a > 100)
{
	cout << a << " ";
	cin >> a;
}

}
Sorry, I don't understand your question. Would you please explain in more detail?
If I run the code.....I see 101 first, then I input 102, then it outputs 102 on the second line.. and so on...

101 102
102 103
103 104
104


Instead of that...I'd like to be able to make the input redirect to the same line instead of outputting to the next line.

101 102 103 104
I don't believe that is possible with just standard cin, when you press enter it will write the newline as well.
Console input is not known for its attractive UI, it really is just basic input/output, without additional libraries.
Last edited on
Topic archived. No new replies allowed.