Display array data like a table?

I need to display my data in a table type form. As it stands now, it lists the data but it isn't straight.

Output as it stands now:

STUDENT ID---NUMERIC GRADE---LETTER GRADE---
172651212---89---B---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
832198439---80.75---B---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
823184903---92---A---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
481284930---66.75---D---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
810849390---54.0833---F---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
831083910---87.75---B---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
819412122---94.8333---A---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
483843110---90.9167---A---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
123123413---89.0833---B---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
311020394---71.6667---C---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
123434390---91.0833---A---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
92348348---58.6667---F---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
145848348---91.5---A---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
673248348---85.5833---B---
STUDENT ID---NUMERIC GRADE---LETTER GRADE---
99288348---93---A---


What I need it to display like (sans the lines between):

STUDENT ID__________NUMERIC GRADE__________LETTER GRADE
187663737___________90.2___________________A
Last edited on
Try tabbing over in your output using "\t" so something like:

cout << arrSSN[c] << "---\t" << arrNumber[c] << "---\t" << arrLetter[c] << "---\t" << endl;

You may need to use more/less and maybe throw some spaces in there depending on how big/small each output is.

Hope this helped!
I believe there is a way to have it display better by using setw[]<<< insert some number in the brackets. I am hoping someone will know how to do this?
I hope this helps...

1
2
3
4
5
6
7
8
9
10
11
#include <iomanip>  // For setw

void deal()
{
	for (int i = 0; i < 52; i++)
		cout  << setiosflags(ios::right)
		         << setw(5) << wDeck[ i ].face << " of " 
			 << setiosflags( ios::left )
			 << setw(8) << wDeck[i].suit
			 << (( i + 1 ) % 2 ? '\t' : '\n');
}

Thanks! Got it!
You're welcome.
I'm having trouble trying to get a card game working.
If you have any advice for me I would appreciate it.
http://www.cplusplus.com/forum/beginner/69961/
Topic archived. No new replies allowed.