I commented your code to show the different problems with what you tried.
Code:
void printFemale(Employee s[], int num) {
int i;
char *F; // this is a char pointer, but it doesn't point anywhere meaningful, it points to garbage
char female[1]; // this doesn't need to be an array, a single char would work
female[0] = 'F'; // you set the one char in the array to 'F' -- this is okay
*F = female[0]; // you assign the char pointed to by F (in garbage memory) to 'F', from the array -- this will likely seg fault or cause other nasty problems
printf( "The Female Employees Are\n");
for( i = 0; i < num; ++i )
{
Trying this statement ---> if (s[i].sex[i] == 'F') // if i is not 0 or 1, you go out of bounds of the sex array. perhaps s[i].sex[0] would work better
Also have tried -----> if (strcmp(s[i].sex, *F) == 0){ // F is a char pointer. if F actually pointed somewhere useful, *F would be the single char it pointed to, which is not what strcmp wants, it wants a char pointer
printf("");
printf("%.2f\n", s[i].pay);
}
}
}
In your case, I would do
Code:
if (s[i].sex[0] == 'F')
// or
if (strcmp(s[i].sex, "F") == 0)
Actually, if you really only intend to store a single character for the sex field in your struct, don't use an array/string, it just confuses you. Just make it char sex;