It looks like your fscanf() is incorrect, in several places.
fscanf(memberSearch, "%s %[^\n] %c %s\n", search.id, search.name, &search.gender, search.contact)
First you're risking buffer overflows when retrieving your strings, you should always use the correct width specifier when retrieving strings.
Second the "%[^\n]" specifier only stops when it encounters the newline character, so it will try to retrieve everything up to the newline character into the supplied variable. If you look at each variable you should find that your have something like:
search_id: "M0001"
search.name: "Cool Name F 123456789"
search.gender: 'M'
search.contact: "0002"
The "%[^\n]" specifier grabs everything until the the end of line, you only want to retrieve the member's name, so you'll need to parse the file differently.
Third your Search structure should probably not needed, just use an array of your "Member" structure (and the instances of the structures should not be global).
1 2 3 4 5 6 7 8 9 10 11
|
typedef struct {
char id[6], name[100], gender, contact[12];
} Member;
int main(void)
{
Member search;
Member members[1000];
...
|
Fourth you may want to consider reading the complete file into your array of Member variable and then search that array for the desired members.
Also be aware that stricmp() is not a standard C function and may not be available with every compiler.