How do you get "absolutely positioned" columns with cout, that leftaligns text and right-aligns numbers?
#include <iostream>
#include <iomanip>
using namespace std;
struct Human {
char name[20];
char name2[20];
char name3[20];
double pts;
};
int main() {
int i;
Human myHumen[3] = {
{"Mr", "Alan", "Turing", 12.25},
{"Ms", "Ada", "Lovelace", 15.25},
{"Sir", "Edgar Allan", "Poe", 45.25}
};
cout << "Name1" << setw(22) << "Name2" << setw(22) << "Name3" << setw(22) << "Rating" <<endl;
cout << "-----------------------------------------------------------------------\n";
for(i = 0; i < 3; i++) {
cout << myHumen[i].name << setw(22) << myHumen[i].name2 << setw(22) << myHumen[i].name3 << setw(20) << myHumen[i].pts << endl;
}//this didn't do nice printouts, with leftalign for text and rightalign with numbers
}