在jGrasp

时间:2017-11-11 02:12:31

标签: c jgrasp

此代码编译时没有错误,但是当我尝试运行它时,它会出现“文件名已停止工作”的Windows错误。它在我编译和链接时没有列出任何错误,并且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] );
   }

}

1 个答案:

答案 0 :(得分:0)

首先,开始添加print语句并确切地确定它崩溃的位置(或者它是否完全没有运行)。