Hello!!!
Im new to this forum, I'm also quite new to C programming and im having some problems with a program
It's a bit long winded so youll have to be patient :-|
The program is about a football league
First Question: Entrying zeros into a variable to be shown in a table...
I would like the output to be something like this
Team P W D L F A T
a 0 0 0 0 0 0 0
s 0 0 0 0 0 0 0
The current code is:
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# define MAX 5
typedef struct entry
{
char fname [31];
short p;
short w;
short d;
short l;
short f;
short a;
short t;
struct entry *next;/*Pointer of type football (which is an entry)*/
}football;
void add (football *);
void print (football *);
short flag1 = 0;
football *head,*current; /*Create two pointer instances of the football type*/
enter()
{
short loop;
if (flag1 ==1)
printf("The array is already full!\n");
else
head = (football *)malloc(sizeof(football));
current=head;
add(current);
for (loop=1;loop<MAX;loop++)
{
current->next=(football *) malloc(sizeof(football));
current=current->next;
add (current);
}
}
void add (football *record)
{
printf("\nEnter football name: ");
gets(record->fname);
record->next = NULL;
}
void print (football *p)
{
puts("\nThe current football league is....");
while( p != NULL) {
printf("Football Name: %s\n",p->fname);
p = p->next;
}
}
Code tags added. -Narue
Thankyou for any help with this problem.