Program doesnt outputs immediately

closed account (42hU7k9E)
This is my program, it should, at least I think so, output every char in the every repeat of the loop, but it doesn't. It outputs all of them at the end of the loop. Why so?

1
2
3
4
5
6
7
8
9
10
11
12
void  main()
{
	for(int i=1; i<10; i++)
	{	
		
		gotoxy(i, 10);
		cout << "-";
		Sleep(100);
	}
}



closed account (42hU7k9E)
ok, I found out that cout is buffered and used a manipulator called flush.

1
2
3
4
5
6
7
8
9
10
11
12
void  main()
{
	for(int i=1; i<10; i++)
	{	
		
		gotoxy(i, 10);
		cout << "-" << flush;
		Sleep(100);
	}
}

Topic archived. No new replies allowed.