Apr 27, 2017 at 10:09pm
I have a problem with spacing in a Phonebook program where I want to tabulate contacts in this form:
1 2 3 4 5 6 7 8 9
|
cout << "-----+----------------------------------------------------------+-----------------------------------------------+" << endl;
cout << " # |\t\t\t\tName\t\t\t\t|\t\t\tPhone\t\t\t|" << endl;
cout << "-----+----------------------------------------------------------+-----------------------------------------------+" << endl;
for (int i = 0; i < 100; i++) {
if (database[i].name != "" && database[i].phone != "") {
cout << " " << database[i].id << " |" << "\t\t" << database[i].name << "\t\t|\t\t\t" << database[i].phone << "\t\t|" << endl;
cout << "-----+----------------------------------------------------------+-----------------------------------------------+" << endl;
}
}
|
The rest of the program functions very fine except for the output of contacts... a deform to the UI happens.
In model case where the spaces are perfect the output goes like this:
http://imgur.com/UUNRFo4
But when I enter a longer/shorter phone number or name, this happens:
http://imgur.com/PGPyDvQ
How can I adjust these spaces so that the "|" seperator can be at a fixed spot? Or any other hints on working-around it?
Last edited on Apr 27, 2017 at 10:12pm