I'm making a game that requires the user to enter a correct username and password to play. I have a list of accepted ones saved in a txt file. How do i read each line of the file and check it with the one entered? I know how to use strcmp(string1, string2). I just need to know how to move from one line to the next. This is what I have for this part of the program so far. Also, I think im using the feof() wrong.
Code:
id = fopen("F://CS223/namepass.txt", "r");
score = fopen("F://CS223/scores.txt", "a");
srand(time(NULL));
if(id == NULL)
{
printf("ERROR");
}
else
{
printf("Enter your name and password, like this: (name_password)\n\n");
gets(input);
while(!feof(id))
{
fscanf(id,"%s",passw);
if(strcmp(input,passw)==0)
{
i=1;
}
else
{
i=0;
}
}
if(i==1)
printf("\nACCESS GRANTED\n\n");
else
{
printf("\n\nACCESS DENIED\n\n");
system("PAUSE");
exit(0);
}
fclose(id);
}