N numbers per line (text file)

closed account (3796URfi)
I need to know how to print numbers from a text file(that include numbers) 10 numbers per line
instead of a output like this:

100
90
80
78
67
56
20
78
99
54
89
100
90
80


I want to have 10 numbers per line like this :

100 90 80 78 67 56 20 78 99 54
89 100 90 80

Can someone please help me do this (from a text file)

What should I put between this
1
2
3
4
5
	while ( !fin.eof())
	{
		
        
	}
closed account (D80DSL3A)
Something like this may work well.
1
2
3
4
5
6
7
int count = 0, num;
while ( fin >> num )
{
    cout << num << ' ';
    if( ++count%10 == 0 )
        cout << endl;// print a newline each time count becomes a multiple of 10    
}
closed account (3796URfi)
thankyou
Topic archived. No new replies allowed.