Попытка добавить значения в мой struct Player, но мой вывод для них после операции является ненужным:
Вывод выглядит так:
Name: Warner
runs: 0
not out: 0
how out: |||||||| (symbols)
Игрок представляет собой структуру:
Player {
int not_out, innings, runs;
char pname[MAX_NAME];
char how_out[5];
}
Вот мой код:
void scan_stats (Team_t player[]) {
int i, status, runs, turns;
char out;
char string[MAX_PLYR];
FILE *inp;
inp = fopen("teamstats.txt", "r");
do
{
fscanf(inp, "%s" "%d" "%*c" "%c", &string, &runs, &out);
printf("%s %d %c\n", string, runs, out); /*They scan perfectly*/
for (i = 0; i < MAX_PLYR; i++) {
player[i].innings = 0;
player[i].runs = 0;
player[i].not_out = 0;
turns = -1;
if (status = (strcmp(player[i].pname, string)) == 0) {
player[i].innings = player[i].innings + 1;
player[i].runs = player[i].runs + runs;
turns = turns + 1;
if (out == 'n') {
player[i].not_out = player[i].not_out + 1;
}
else {
player[i].how_out[turns] = out;
}
}
}
} while (!feof(inp)); /*Printing the values of player at the end of this loop
produces garbage/ incorrectness*/
fclose(inp);
}