Help checking a character in a structure
I am currently writing a function that checks whether a character string contains an "F" or "M". I have tried strcmp() and a if statement. Here is the code I have tried, any help would be much appreciated.
Code:
void printFemale(Employee s[], int num) {
int i;
char *F;
char female[1];
female[0] = 'F';
*F = female[0];
printf( "The Female Employees Are\n");
for( i = 0; i < num; ++i )
{
Trying this statement ---> if (s[i].sex[i] == 'F')
Also have tried -----> if (strcmp(s[i].sex, *F) == 0){
printf("");
printf("%.2f\n", s[i].pay);
}
}
}
The code for the struct is as follows:
Code:
typedef struct Employee
{
char first[8];
char initial[2];
char last[10];
Address ad;
int age;
char sex[2];
int years;
double pay;
}Employee;
I have a number of other structures that work, but when checking the character in sex[2] I just seem to be missing something.
Thank you again.