output problems

Current output:

Unsorted Data:

      1      2      3      4      5      6      7      8      9      10      11   
 12     13     14     15     16     17     18     19     20     21     22     23


I want it to line up nicely.
Example:

      1      2      3      4      5      6      7      8      9     10     11
     12     13     14     15     16     17     18     19     20     21     22

I'm using
1
2
3
4
5
	for (int i=0; i<size; i++)
	{
		cout << setw(7) << A[i];
		fout << A[i];
	}
Last edited on
What I believe is happening is it's wrapping around the text. I want it to start on a new line if it hits the end of the line in the middle of an output
well, where a text editor decides to do word wrap is just based off the window size.

you just need to pick a spot to start a new line, say halfway.
{
cout << "\t" << A[i];
}
{
cout << "\t" << A[i];
}

Um, no. That won't fix the OP's problem, which is that he's writing one very long line which is wrapping.
for(int i2 = 0;i2 < 11;i2++)
{
cout << endl;
}

// place within first loop
Um, no. That will print 11 end-lines after ever number.
1
2
3
4
5
6
	for (int i=0; i<size; i++)
	{
		cout << setw(7) << A[i];
		if ( i % 12 == 11 ) cout << endl;
		fout << A[i];
	}
Topic archived. No new replies allowed.