의 정의가 충돌하는 유형 정의 getGameInfo
의 정의는 자체 프로토 타입과 충돌하는 유형 오류를 제공합니다.프로토 타입
#include <math.h>
#include <stdio.h>
//FUNCTION PROTOTYPES============================================
//print report title and column headers
void printHeaders(int year, int month, int day);
//print game info and footer with averages
void printGameInfo(int year, int month[], int day[], int auscore[], int oppscore[], int numGames);
//print footer with average and larges point spread
void printFooter(int auscore[], int oppscore[], int numGames);
//open and read file into 1D arrays and return #games
int getGameInfo(FILE* filePtr, int month[], int day[], int auscore[], int oppscore[]);
//return the average on an int array
double mean(int array[], int count);
int main()
{
int month[15], day[15], auscore[15], oppscore[15], numGames;
#define thisyear 2017
#define lastyear 2016
FILE *THISYEAR; // pointer to data file
FILE *LASTYEAR; // pointer to data file
THISYEAR = fopen("Auburn Football 2017.txt", "r");
LASTYEAR = fopen("Auburn Football 2016.txt", "r");
if (THISYEAR == NULL || LASTYEAR == NULL) //bad open
printf("Error opening input file.");
else //good open
{
getGameInfo(LASTYEAR, month, day, auscore, oppscore);
printGameInfo(lastyear, month, day, auscore, oppscore, numGames);
//rest of program ...
}
}
int getGameInfo(FILE* filePtr, int *month[], int *day[], int *auscore[], int *oppscore[])
{
int numGames;
for (numGames = 0; numGames < 14; numGames++)
{
fscanf(filePtr, "%d", &month[numGames]);
fscanf(filePtr, "%d", &day[numGames]);
fscanf(filePtr, "%d", &auscore[numGames]);
fscanf(filePtr, "%d", &oppscore[numGames]);
}
return numGames;
}
void printGameInfo(int year, int month[], int day[], int auscore[], int oppscore[], int numGames)
{
printHeaders(year, month[numGames], day[numGames]);
printFooter(auscore, oppscore, numGames);
}
void printHeaders(int year, int month[numGames], int day[numGames])
{
printf("%d Auburn Football Season as of %d/%d", &year, &month[numGames], &day[numGames]);
printf("Date Auburn Opp");
}
void printFooter(int auscore[], int oppscore[], int numGames)
{
double avoppscore, avauscore;
avoppscore = mean(oppscore, numGames);
avauscore = mean(auscore, numGames);
printf(" Ave score %lf %lf ", avauscore, avoppscore);
}
double mean(int array[], int count)
{
int i;
double average, sum = 0;
for (i = 0; i < count; i++)
{
sum += array[i];
}
average = sum/count;
return average;
}
'printHeaders()'에는 사용되지 않은 매개 변수가 있습니다 :'month' 해당 매개 변수의 제거를 제안하거나 해당 매개 변수를 사용하기위한 함수를 수정하십시오. 비슷한 고려 사항이 'day' 매개 변수에 해당합니다 .. – user3629249
문은' fscanf (filePtr, "% d", 그리고 month [numGames]);'** int' 매개 변수를 전달하지만'* int' 매개 변수를 전달해야합니다 불필요한'&' – user3629249
제거 제안 :'void printHeaders int numGames, int day [numGames])'변수 :'numGames'가 정의되지 않았습니다. 제안 : void printHeaders (int numGames, int year, int month [], int day []) 'fopen()'을 호출 할 때 프로토 타입과이 함수의 모든 호출을 – user3629249