Hey, I'm currently trying to do a project, I have in a file.txt the info of several people, each line has their age, name and gender (Ex: 18,Paul Walker,Male), I'm trying to just print the age and name of the person if they are male and just the name if they are female.
I did:
fgets(line, 200, file); //to get each string from the file.txt
sscanf(line, "%d,%[^,],%[^,]", &age, name, gender); //store each value in a variable
however when I tried to do:
if(gender == "male"){
printf("%d, %s\n", age, name);
} else if(gender == "female") {
printf("%s\n", name);
}
to try to just show their name if they are female and the name + age if they are male, it doesen't work, how do I fix this? And then with the info that I just printed, how do I create a seperate file and put it in there?