I have been working on my final project that i am going to do a simple soccer game. Not graphical. I will ask the user to choose or create a team. Teams are saved in the same file as the code as text files. where i am stuck is, i need to create a league of 8 teams randomly and have them match up with each other for the each game. I can't really figure out how to do this.
#define Arsenal "arsenal.txt"
#define Barcelona "barcelona.txt"
#define Bayern_Munich "bayern munich.txt"
#define Chelsea "chelsea.txt"
#define Juventus "juventus.txt"
#define Liverpool "liverpool.txt"
#define Manchester_United "manchester united.txt"
#define Porto "porto.txt"
#define Real_Madrid "real madrid.txt"
...
void choose_team(char teams[9][100],char players[10][100],int team_choice);
void create_league(int team_choice,char teams[9][100],
char league[8][100],int drawing[9][100]);
...
void choose_team(char teams[9][100],char players[10][100],int team_choice)
{
FILE *fh = NULL;
int i = 0;
switch(team_choice)
{
case 1:{
system("cls");
printf("Your team is:Arsenal\n");
printf("Your players are:\n");
fh = fopen(teams[0],"r");
// Repeat until I reach end of file
while (! feof(fh))
{// Read a string from the file
fgets(players[i], 100, fh);
// Get rid of the newline
if(players[i][ strlen(players[i]) - 1 ] == '\n')
players[i][ strlen(players[i]) - 1 ] = 0;
printf("%s\n", players[i]);
// Increment the counter
i++;
} // end of while
fclose(fh);
break;
}
....// choices go like that
void create_league(int team_choice,char teams[9][100],
char league[8][100],int drawing[9][100])
{}