Ich lerne C++. Ich habe ein Problem beim Formatieren der Ausgabe meines Programms. Ich möchte dort Spalten perfekt ausgerichtet drucken, aber so weit ich kann es nicht tun, hier ist mein Code:Ausgabe ausgerichtet Spalten
int main()
{
employee employees[5];
employees[0].setEmployee("Stone", 35.75, 053);
employees[1].setEmployee("Rubble", 12, 163);
employees[2].setEmployee("Flintstone", 15.75, 97);
employees[3].setEmployee("Pebble", 10.25, 104);
employees[4].setEmployee("Rockwall", 22.75, 15);
printEmployees(employees, 5);
return 0;
}
// print the employees in my array
void printEmployees(employee employees[], int number)
{
int i;
for (i=0; i<number; i++) {
employees[i].printEmployee();// this is the method that give me problems
}
cout << "\n";
}
in der Klasse Angestellter den Druck Mitarbeiter Methode haben:
void printEmployee() const
{
cout << fixed;
cout << surname << setw(10) << empNumber << "\t" << setw(4) << hourlyRate << "\n";
}
Problem ist, wenn Ich drucke "Flinstones" Linie die Emp-Nummer und Rate sind nicht aufgereiht. so etwas passiert:
Stone 43 35.750000 Rubble 163 12.000000 Flintstone 97 15.750000 Pebble 104 10.250000 Rockwall 15 22.750000
Kann mir jemand helfen? (Ich habe versucht, Registerkarten hinzuzufügen .. aber es hat nicht geholfen)
http://stackoverflow.com/questions/275484/cout-formatting – Kirby