SuperSharp
Programmer
Hello!
I have been given an assignment to create a league table in C. Basically a series of match results are to be entered by the user and an updated league table is to be produced. Which looks something like this:
P W D L F A T
Galatasaray 2 1 1 0 4 3 4
Juventus 2 0 2 0 3 3 2
Rosenborg 2 0 2 0 2 2 2
Atlentico 2 0 1 1 2 3 1
I am uber new to this whole programming thing, my teacher here at uni is terrible, and I am really confused. I have spent hours trying to figure this out but so far all I have come up with is the main menus etc (which i am dead proud of!!!). I have also made an array for the team names which I can now add one at a time, and I figured that I have to make a 2d array for the scores part. I have given this a go, but I do not know how to display only the amount thats currently in the array and not the blank spaces after. At this point we don't have to worry about sorting them in any particular order, just trying to get it to display ^like that is hard enough.
Does anyone have any ideas how this could be done, and how I could display this table. Any help would be really appreciated as I am going nuts and have my first demo soon
Thanks very much for taking the time to read this.
Edd
P.S: The code below is what I have done so far for 2 of the fuctions, in the 'print_teams' function, I thought about trying to get it to read the length of the array and only diaplaying how many teams are entered, as right now it prints the teams and lots of black spaces and what ever was last in the memory location.
I have been given an assignment to create a league table in C. Basically a series of match results are to be entered by the user and an updated league table is to be produced. Which looks something like this:
P W D L F A T
Galatasaray 2 1 1 0 4 3 4
Juventus 2 0 2 0 3 3 2
Rosenborg 2 0 2 0 2 2 2
Atlentico 2 0 1 1 2 3 1
I am uber new to this whole programming thing, my teacher here at uni is terrible, and I am really confused. I have spent hours trying to figure this out but so far all I have come up with is the main menus etc (which i am dead proud of!!!). I have also made an array for the team names which I can now add one at a time, and I figured that I have to make a 2d array for the scores part. I have given this a go, but I do not know how to display only the amount thats currently in the array and not the blank spaces after. At this point we don't have to worry about sorting them in any particular order, just trying to get it to display ^like that is hard enough.
Does anyone have any ideas how this could be done, and how I could display this table. Any help would be really appreciated as I am going nuts and have my first demo soon
Thanks very much for taking the time to read this.
Edd
P.S: The code below is what I have done so far for 2 of the fuctions, in the 'print_teams' function, I thought about trying to get it to read the length of the array and only diaplaying how many teams are entered, as right now it prints the teams and lots of black spaces and what ever was last in the memory location.
Code:
/**********************************************************/
/* Stores a new team */
/**********************************************************/
void read_teams(char s[][21], int n)
{
static int t;
printf("\nPlease enter a new team\n");
{
gets(s[t]);
t++;
}
}
/**********************************************************/
/* Displays the current teams */
/**********************************************************/
void print_teams(char list[][21], int n)
{
int i = 0;
printf("\nThe current Teams are:\n\n");
while (i != 11)
{
//print each row list [i] as string
printf("%s\n", list[i]);
i++;
}
}