comparing strings: case INsensitive
I'm trying to write a program that takes in a list of names and ages, then searches for a certain first name and last name. However, in the problem prompt, it requires that the comparison between the name and search value to be case insensitive. I've tried stricmp() but I don't think the compiler I'm using uses it (GCC). Here's my code for my search() function so far.
Code:
int search( char names[20][20], int ages[20], char value[20], int *totAges )
{
char tempArr[20];
int rCtr = 0;
int cCtr = 0;
int ctr = 0;
int ageCtr = 0;
for( rCtr = 0; rCtr < 20; rCtr++ ) {
strcpy( tempArr, names[rCtr] );
if( !strcmp( tempArr, value ) ) {
ctr++;
printf( "%d\n", ages[rCtr] );
ageCtr += ages[rCtr];
}
}
*totAges = ageCtr;
return ctr;
}
Any help would be greatly appreciated. Thanks!