char sInputString[512];
char sFirstName[512];
char sLastName[512];
int iFoundIndex = -1;
int i;
int j;
/* Ask the user to input any values you want to compare */
cout << "Please enter the person's First name: ";
cin >> sInputString;
/* convert all characters to upper case */
for (j = 0; j < strlen(sInputString); j++)
{
sFirstName[j] = toupper(&sInputString[j]);
}
/* append a null character */
sFirstName[j] = '\0';
cout << "Please enter the person's Last name: ";
cin >> sInputString;
/* convert all characters to upper case */
for (j = 0; j < strlen(sInputString); j++)
{
sLastName[j] = toupper(&sInputString[j]);
}
/* append a null character */
sLastName[j] = '\0';
/*
* Fill your structure and set MaxStructureSize
* before continuing!
*/
/* Now look for the right record */
for (i = 0; i < iMaxStructureSize; i++)
{
/* convert all characters to upper case */
for (j = 0; j < strlen(MyStruct[i].sFirstName); j++)
{
sWorkString[j] = toupper(&sMyStruct[i].sFirstName[j]);
}
/* append a null character */
sWorkString[j] = '\0';
if (strstr(sWorkString, sFirstName) != NULL)
{
// you found the first name, now check the last name
/* convert all characters to upper case */
for (j = 0; j < strlen(MyStruct[i].sLastName); j++)
{
sWorkString[j] = toupper(&sMyStruct[i].sLastName[j]);
}
/* append a null character */
sWorkString[j] = '\0';
if (strstr(sWorkString, sLastName) != NULL)
{
// you found the last name, set flag and exit loop
iFoundIndex = i;
break;
}
}
}
if (iFoundIndex >= 0)
{
// use MyStruct[iFoundIndex].sLastName or whatever...
}