Searching for a String within a file
I'm making a program that stores peoples info in a file. Each Person's info is a New line ex:
John <info>
doug <info>
I need to be able to search for the person's name to pull the info from the file into a struct. I'm not quite sure how to compare the strings. here's a snipit of the code:
FILE * input_file;
struct
{
char name[20];
int age; // theirs more, but not important.
} Info_Struct;
int main(void)
{
char name[20];
char file_name[20];
printf("What is your name: ");
scanf("%s",name);
input_file = fopen("d:\\test.dat","r");
fscanf("%s",file_name);
//here's where I need to compare the names to see if the
//first name in the file is correct, or if I need to go to the
// nest line. I'd like to use an if statement, but if theirs
//something better, I think I could live.
}
I'm using DevC++