I have 2 functions below. How do I change the code so that it will display by letter?
e.g if I define “A”, it will only showAllRecords that begin with A.
char* displayRecordContent (CountryRecordType ctryRec)
{
char * output;
output = ctryRec.Country;
return output;
}
// ====================================================================
void showAllRecords ()
{
int i=0;
char * result;
for (i=0; i<NoOfRecordsRead; i++)
{
result = displayRecordContent (globalCountryDataArray [i]);
printf ("(%d) %s\n", i, result);
}
}
Output:
(0) Andorra
(1) United Arab Emirates
(2) Afghanistan
(3) Antigua and Barbuda
(4) Anguilla
(5) Albania
(6) Armenia
(7) Netherlands Antilles
(8) Angola
(9) Antarctica
1 Answer