Let me start by saying I am new to this forum and new to C programming. I am struggling with the concept of storing 2 teams scores in a 2 d array from a menu based system. Yes, this is a homework assignment, and I am not asking anyone to write the assignment for me. I just would like to understand why my code is not placing values as I would expect them to. I am here to learn, I am taking the project one piece at a time. The menu functions and does work, the next step was placing elements in the array. This does not work sadly. Thank you in advance.
Code:
/
// main.c
// game_scores
//
// Created by on 1/24/19.
// Copyright © 2019 game_scores. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#define score 100
#define teams 2
// declare functions
void display_menu(void);
void game_result(void);
void list_scores(void);
void games_won(void);
void scores_sort(void);
// declare variables
int game[score] [teams] , j = 0, i = 0;
char choice;
int main()
// call menu
{
display_menu();
return 0;
}
// display menu options
void display_menu(void)
{
do
{
printf("\n\n************************* \n");
printf("** MAIN MENU *** \n");
printf("************************* \n\n");
printf("[A]Enter game result \n");
printf("[B]Current Record(# of wins and # of losses and # of ties \n");
printf("[C]Display ALL results from all games WON \n");
printf("[D]Display ALL results ordered by oponent score from low to high. \n");
printf("[E]Quit the program \n");
printf("Enter an option:");
scanf(" %c",&choice);
// set menu options
switch(choice)
{
case 'A': game_result();
break;
case 'B': list_scores();
break;
case 'C': games_won();
break;
case 'D': scores_sort();
break;
case 'E': printf("Quitting program!\n");
exit(0);
break;
default: printf("Invalid choice!\n");
break;
}
} while (choice != 'E');
}
// begin function items
//*********************
// loop through game score values
void game_result(void)
{
for(i=0; i<score; i++)
for(j=0;j<teams;j++)
game [i][j] = 0;
printf("Enter game scores:");
scanf("%d", &game[i][j]);
return;
}
// list game scores in array
void list_scores(void)
{
return;
}
// sort the by games won
void games_won(void)
{
return;
}
// sort score values
void scores_sort(void)
{
return;
}