Code:
/*start of files with structs*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STRING_LENGTH 100
#define ROUND_LENGTH 6
typedef struct {
int round_match, day, month, year, hour, min, goal_side1, goal_side2;
char team1[STRING_LENGTH];
char team2[STRING_LENGTH];
char supporters[STRING_LENGTH];
} matches;
typedef struct{
int round_round, goal1, goal2, day1, month1, year1, hour1, min1;
char team3[STRING_LENGTH];
char team4[STRING_LENGTH];
char supporters1[STRING_LENGTH];
} round;
typedef struct{
char hometeam[STRING_LENGTH];
char awayteam[STRING_LENGTH];
} teams;
void goalroundplus();
/* main function in here which calls the other function*/
/* functions below */
void goalroundplus(){
FILE *fp;
int x = 0;
int i = 1;
int goalsround[33];/* = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ,13 ,14, 15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33";*/
int c = 1;
int goals = 0;
matches *info = calloc(199, sizeof(*info));
/*round *roundarray = calloc(33, sizeof(*roundarray));*/
fp = fopen("scorefile.txt", "r");
while(fscanf(
fp,
"%d %d.%d.%d kl. %d.%d %s - %s %d - %d %s",
&info[x].round_match,
&info[x].day,
&info[x].month,
&info[x].year,
&info[x].hour,
&info[x].min,
info[x].team1,
info[x].team2,
&info[x].goal_side1,
&info[x].goal_side2,
info[x].supporters
) != EOF){
}
fclose(fp);
}
It's just after i call my function in the while loop, where i'm supposed to have put information into a new array of structs i think, then compare it somehow, and print the round with most goals. I've tried but have been unsuccesfull, and my mind is really blowing up.