i have been debugging the whole night, it is very confusing that the console always jump to ask me the second runner's name, but dont give me the change to input the first runner's name.
here is segment in my main.c
Trunner runners[10]; Trunner best; int n,i; const char* name = "give the name for runner "; const char* time = "give the time for runner "; printf("How many names you have?"); scanf("%d",&n); for(i=0;i<n;i++){ readTime(&runners[i],time); } for(i=0;i<n;i++){ readName(&runners[i],name); } here is my runner.c
void readName(Trunner *runner, const char *prompt){ printf(prompt); fgets (runner->name,30,stdin); //getchar(); } and what i got, the name of runner should be in the same line as the comma, and as you can see, the first runner's name is empty.
How many names you have?3 give the time for runner 11:13 give the time for runner 14:14 give the time for runner 12:13 give the name for runner give the name for runner lily give the name for runner lucy the winner is: , 11:13 , 11:13 0:0 lily , 14:14 3:1 lucy , 12:13 1:0 Press any key to continue . . .