I have a program with alot of data stored in a file and gets loaded into structs.
I have an option so the user can change some information but since I don't know what he wants to change I need to printf and scanf all the information of the item he wants to change.
This is a part of the program:
char check;
if(p->vetor.id == jogo){
printf("Reference: %d\n", jogo);
fflush(stdin);
printf("\nTeam 1: ");
if(getchar() != '\n'){ // METHOD 1
gets(p->vetor.eqTeam1);
}
fflush(stdin);
printf("\nTeam 2: ");
if(scanf("%c", &check) && check != '\n'){ //METHOD 2
gets(p->vetor.eqTeam2);
}
fflush(stdin);
}
It checks if the input is a ENTER (and it works) but when I write something there it "eats" the first letter because it needs to check before if is a ENTER or not, is there a way to give the lost letter back to the gets() ?
Thanks for your help.