So my question is simple. In C++, is there a way to align text so when it prints to the screen it is nicely lined up? Note: I have two strings coming in via a struct. Having two strings of different lengths coming in gives a need for a changing setw(). I tried to use strlen but it gave me a compiler error.
My output is:
Lastname, Firstname Record Number ###
Joe, John Record Number 3
Joseph, John Record Number 4
The difficulty I am having is making the record Number lineup.
/******************************************************
* Input member
* Output Text
* looks for a specfic name in the list.
* then couts name to user
*****************************************************/
int display(Record member[], string name,int i)
{
char length[256];
string checkLastName = member[i].last;
string first = member[i].first;
if (checkLastName == name)
{
cout << endl << member[i].last
<< ", " << member[i].first
<< setw(20) << "Record Number: "
<< (i - 2) << endl;
i = 0;
return 0;
}
else
i++;
if (i >= 142)
{
cout << "Not found\n";
return 0;
}
display(member, name, i);
}
Any help would be greatly appreciated thank you.
-Erick