Code:
/** Enters Team Name **/
int initialise(team_info * arrdetails,
const int numofteams)
{
/** if not reading from file... **/
int i = 0;
char rtn = 0;
int j;
int num_teams = 0;
for(i = 0; i < numofteams; i++)
{
char teamd[16];
printf("\nPlease enter team name:\n>");
scanf("%s%c", teamd, &rtn);
for(j = 0; j < i; ++j)
{
int match = strcmp(teamd, arrdetails[j].team) == 0;
if(match)
{
printf("Sorry, this team already exists. Please try again!");
break;
}
else
{
strcpy(arrdetails[i].team, teamd);
arrdetails[i].played = 0;
arrdetails[i].won = 0;
arrdetails[i].lost = 0;
arrdetails[i].draw = 0;
arrdetails[i].points = 0;
arrdetails[i].goalsfor = 0;
arrdetails[i].goalsagainst = 0;
arrdetails[i].goalsd = 0;
arrdetails[i].team_id = num_teams;
num_teams++;
}
}
}
return num_teams;
}
At the moment my application will only allow me to enter team names such as:
'ManchesterUtd' instead of 'Manchester Utd'
'BlackburnRovers' instead of 'Blackburn Rovers'
Any ideas on how I can enhance my application to allow a multi-worded entry?
Thanks