Hi

I have the following code below but it doesn't seem to work . Anyone here who knows C can look at it and help me locate the errors ?

thanks



#include "stdio.h"
#include "conio.h"

#define MAX_TEAM 12

// Number of teams
int nteams = 0;
// Team names (up to MAX_TEAM teams). Name is up to 24 chars (+1 for zero).
char teams[MAX_TEAM][25];

// Team record in league table
typedef struct TEAM_RECORD
{
// Number of matches
int played;
int won;
int drawn;
int lost;
// Goals
int goals_for;
int goals_against;
// Total points
int total;
};

// Array for league table
struct TEAM_RECORD table[MAX_TEAM];

void inputTeams()
{
char c;
if(nteams==MAX_TEAM)
{
printf("All %d teams are entered already.\n\r", MAX_TEAM);
return;
}
do
{
printf("Enter team name: ");
gets(&teams[nteams]);
nteams++;
if(nteams==MAX_TEAM)
break;
printf("Would you like to enter another team? (y/n) ");
c = getche();
printf("\n\r");
}while(c=='y' || c=='Y');
}

void displayTable()
{
int i;
printf(" Team P W D L F A T\n\r");
for(i=0; i < nteams; i++)
printf("%24s %2d %2d %2d %2d %2d %2d %2d\n\r", teams[i],
table[i].played, table[i].won, table[i].drawn, table[i].lost,
table[i].goals_for, table[i].goals_against, table[i].total);
printf("\n\rPress any key to return to Main Menu ");
getch();
printf("\n\r");
}

void inputMatches()
{
int i;
int team1, team2, score1, score2;
int c;
if(nteams==0)
{
printf("Please enter teams first\n\r");
return;
}
do
{
// print all teams
printf("\n\rTeams:\n\r");
for(i=0; i < nteams; i++)
printf("%2d %s\n\r", i+1, teams[i]);
printf("Enter index of first team in match: ");
scanf("%d", &team1);
team1--; // to count from zero
printf("Enter goals for %s: ", teams[team1]);
scanf("%d", &score1);
printf("Enter index of second team in match: ");
scanf("%d", &team2);
team2--; // to count from zero
printf("Enter goals for %s: ", teams[team2]);
scanf("%d", &score2);
table[team1].played++;
table[team2].played++;
if(score1 > score2)
{
table[team1].won++;
table[team2].lost++;
}
else if(score1 < score2)
{
table[team1].lost++;
table[team2].won++;
}
else // draw
{
table[team1].drawn++;
table[team2].drawn++;
}
table[team1].goals_for += score1;
table[team1].goals_against += score2;
table[team2].goals_for += score2;
table[team2].goals_against += score1;
table[team1].total = table[team1].won*3 + table[team1].drawn;
table[team2].total = table[team2].won*3 + table[team2].drawn;

printf("Would you like to enter another match results? (y/n) ");
c = getche();
printf("\n\r");
}while(c=='y' || c=='Y');
}

int main(int argc, char* argv[])
{
int exit = 0; // exit from main loop flag
char c;
// main loop
do
{
printf("\n\r==========");
printf("\n\rMain Menu:\n\r");
printf("a. Entry of teams\n\r");
printf("b. Display current table\n\r");
printf("c. Enter match details\n\r");
printf("d. Exit system\n\r");
printf("Your choice: ");
c = getche();
printf("\n\r\n\r");
switch(c)
{
case 'a':
case 'A':
inputTeams();
break;
case 'b':
case 'B':
displayTable();
break;
case 'c':
case 'C':
inputMatches();
break;
case 'd':
case 'D':
// set exit flag
exit = 1;
break;
default:
printf("Please select a-d.\n\r");
}
} while(exit!=1);
return 0;
}