Write a program in C language that first reads the results of the games held in the…
- User
Write a program in C language that first reads the results of the games held in the Iranian Premier League from a file called play.txt.This file contains the following informationWeek number (WeekNo) which is a number between 1 and 30The name of the host team (HomeName, which is a name with a maximum of 20 characters).The name of the guest team (GuestName), which is a name with a maximum of 20 charactersThe number of goals scored by the home team (gole, which is an integer between 0 and 100).The number of goals scored by the away team (Ggole), which is an integer between zero and 100Figure 1 shows the results of week 30.Then another file named team.txt is created to store the points of each team and in this file the information of 16 teams in the Iranian Premier League is copied as follows.team name (club)Number of games (MP)Number of games won (W)Number of games lost (L)Number of tie games (D)Number of goals scored (GF)Goals scored (GA)Flower Difference (GD)Points of each team (Pts)The points of each team are obtained according to the results of the gamesThe winning team has 3 points, the losing team has 0 points and if the game is equal, 1 point. and i want this code to fill up the information from play.txt file
- Assistant
- User
teamFile = fopen(teamFileName, “w”); if (teamFile == NULL) { printf(“Error: cannot create %s file\n”, teamFileName); return 1; } for (int i = 0; i < numTeams; i++) { fprintf(teamFile, “%s %d %d %d %d %d %d %d %d\n”, teams[i].name, teams[i].MP, teams[i].W, teams[i].L, teams[i].D, teams[i].GF, teams[i].GA, teams[i].GD, teams[i].Pts); } fclose(teamFile);
return 0; this part have too many errors
- Assistant
Thank you for bringing this to my notice. Can you please specify the errors you are experiencing, so that I can correct them?