This section of my code is faulty, and I have no idea how to fix it. Please help.
void printContacts(Person contacts[], int count)
{
char field;
bool okay;
string temp;
cout %26lt;%26lt; "Sort list by [F]irst or [L]ast name: ";
cin %26gt;%26gt; field;
for(int i = 0; i %26lt; count; i++)
{
okay = isOutOfOrder(contacts[i], contacts[i + 1], field);
if(okay)
{
}
else
{
temp = contacts[i + 1];
contacts[i + 1] = contacts[i];
contacts[i] = temp;
}
}
for(int f = 0; f %26lt; count; f++)
{
printContacts(contacts);
}
}
bool isOutOfOrder(Person p1, Person p2, char field)
{
if(field == 'F' || field == 'f')
{
return (p2.firstname %26lt; p1.firstname);
}
else
{
return(p2.lastname %26lt; p1.lastname);
}
}
I can't get my c++ code to compile?
Not enough info to help you. Need:
1. to see data type 'Person', and/or...
2. to know what is the error message you get during compile?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment