I've researched alot and I simply cannot find something that actually works in my program. The best method I've found (AKA, the only one that kind of works) involves adding a spare char in the text file to be read and it checked if the file ended based on that, but I have to read other files and check if they ended and this same method simply doesn't work with these other files, so I need a better method that actually works. Right now I'm trying this method you see below (using feof) and it's doing nothing, the program goes to that if, checks that it isn't the end of the document and loops again, and keeps doing it even after the file ended.
int main(){
FILE *contas; //ponteiro do arquivo onde as contas estão salvas
contas = fopen("Contas.txt","r"); //abre arquivo onde as contas estão salvas
system("color F0"); //altera a cor da fonte e do background
setlocale(LC_ALL, "portuguese"); //define a língua utilizada pelo programa
do{
system("cls"); //limpa a tela
printf("\n\n\tBem-vindo! Por favor, insira o seu login e a sua senha.");
printf("\n\tLogin: ");
scanf("%s", login); //recebe o login inserido pelo usuario
printf("\tSenha: ");
scanf("%s", senha); //recebe a senha inserida pelo usuario
do{
fscanf(contas,"%s %s",loginSalvo,senhaSalva); //lê o arquivo, login/senha por login/senha
if(strcmp(login,loginSalvo) == 0 && strcmp(senha,senhaSalva) == 0){ //compara login/senha inserido com o login/senha do arquivo
printf("\tLogin efetuado com sucesso!\n\t");
system("pause");
verificacaoValidez = 1;
}else{
if(feof(stdin)){ //verifica se o arquivo inteiro já foi lido
printf("\tLogin e/ou senha incorretos, tente novamente\n\t");
system("pause");
break;
}
}
}while(verificacaoValidez != 1); //repete enquanto o login/senha estiver incorreto
}while(verificacaoValidez != 1); //repete enquanto o login/senha estiver incorreto
fclose(contas); //fecha arquivo das contas
}