2017-11-11 10 views
0

このコードはエラーなしでコンパイルされますが、実行しようとすると「ファイル名が機能しなくなりました」というウィンドウエラーが表示されます。コンパイルとリンク時にエラーが表示されず、jGraspプログラムでエラーが発生しませんが、実行するたびにウィンドウにエラーボックスが表示されます。私はそれを修正する方法をあなたが与えることができる任意の助けを感謝されるかわからない。 Plsはprint文の追加を開始し、それがクラッシュしている(または、それがすべてで実行されていない場合)場所を正確に把握、jGraspのwindowsエラー実行プログラム

#include <math.h> 
#include <stdio.h> 
//FUNCTION PROTOTYPES======================================================= 
// print report title and column headers 
    void printHeader(int month, int day); 

// print game information report 
    void printGameInfo(int date[][2], int auscore[], int oppScore[],  double gameLen[], 
        int attend[], int numGames); 

// open and read file into arrays return #games  
    int getGameInfo(FILE* filePtr, int date[][2], int auScore[], int oppScore[], 
        double gameLen[], int attend[]); 

// find the max of an integer array 
    int maxInt(int array[], int count); 

// find the max of a double array 
    double maxDouble(double array[], int count); 
//============================================================================ 

int main (){ 
#define MAXGAMES 15 
#define year 2017 
    int day, 
    numGames, 
    month; 
    int date [MAXGAMES][2], 
    auScore [MAXGAMES], 
    oppScore [MAXGAMES], 
    attend [MAXGAMES]; 
    double gameLen [MAXGAMES]; 
    FILE *GAMEDATA; 
    GAMEDATA = fopen ("seasonStats2017.txt","r"); 
    if (GAMEDATA == NULL)//bad open 
     printf("Error opening input file."); 
    else //good open 
     {//find and print last year's data 

     numGames = getGameInfo(GAMEDATA, date, auScore, oppScore, 
         gameLen, attend);   

     printGameInfo(date, auScore, oppScore, gameLen, 
        attend, numGames); 
     } 
    return 0; 
    }   

void printHeader(int month, int day) 
    { 
     printf("  \n%d AUBURN TIGERS", year); 
     printf("\n%d Auburn Games Results (as of %02d/%02d) \n", year, month,   day); 
     printf("Date Score W-L Length Attend"); 
     printf("----- ----- --- ------ ------"); 
    } 


int getGameInfo(FILE* filePtr, int date[][2], int auScore[], int oppScore[], 
         double gameLen[], int attend[]) 
{ 
    int k = 0, 
     minutes[MAXGAMES], 
     hours[MAXGAMES], 
     day[MAXGAMES], 
     month[MAXGAMES]; 

    while ((fscanf(filePtr,"%d", &month[k])) == 1) 
    { 
     fscanf(filePtr,"%d", &day[k]); 
     fscanf(filePtr,"%d", &auScore[k]); 
     fscanf(filePtr,"%d", &oppScore[k]); 
     fscanf(filePtr,"%d", &hours[k]); 
     fscanf(filePtr,"%d", &minutes[k]); 
     fscanf(filePtr,"%d", &attend[k]); 
     date[k][0] = month[k]; 
     date[k][1] = day[k]; 
     gameLen[k] = hours[k] + (minutes[k]/60); 
     k++; 
    } 
    return k-1; 
} 


double maxDouble(double array[], int count){ 
int i; 
double highest = array[i]; 
    for(i = 0; i < count; i++) { 
    if(highest<array[i]) 
      highest = array[i]; 
    } 
    return highest; 
} 


int maxInt(int array[], int count){ 
int i; 
    int highest = array[i]; 
    for(i = 0; i < count; i++) { 
    if(highest<array[i]) 
      highest = array[i]; 
    } 
    return highest; 
} 


void printGameInfo(int date[][2], int auScore[], int oppScore[], double   gameLen[], 
        int attend[], int numGames){ 
     int maxI, 
     maxD, 
     month, 
     day, 
     i; 
     maxI = maxInt(attend, numGames); 
     maxD = maxDouble(gameLen, numGames); 
    month = date[numGames][0]; 
    day = date[numGames][1]; 
    printHeader(month, day); 
    for (i=0; i<= numGames; i++) 
    { 
     printf (" %02d/%02d %2d - %2d", date[i][0], date[i][1], auScore[i], oppScore[i]); 
     if (auScore[i]>oppScore[i]){ 
     printf("W"); 
     } 
     else{ printf("L"); 
     } 
     printf (" %3.2lf %5d ", gameLen[i],attend[i]); 
    } 

} 

答えて

関連する問題