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.

Well, if you had read the thread at the top stating "Please use BB code tags", this would be much easier to work with.... but I'm sure Narue will come through and add them, but don't get used to it ;)

So... what is the program doing that it shouldn't? I don't see any actual questions in your post and don't feel like going through unformated code... so you will need to define the problem before we can help you

Well, if you had read the thread at the top stating "Please use BB code tags", this would be much easier to work with.... but I'm sure Narue will come through and add them, but don't get used to it ;)

So... what is the program doing that it shouldn't? I don't see any actual questions in your post and don't feel like going through unformated code... so you will need to define the problem before we can help you

Oops sorry :o

Where are the "BB code tags"!!!...
Yeah theres nothing wrong with the code, when the user has finished entering the team names they should appear in a list like:

Team W L D F A T

team 1 0 0 0 0 0 0
team 2 0 0 0 0 0 0

At the moment it just shows the team names??? I need to initialise the zeros to appear after the team names when the table shows on screen within the print function. Is this possible???

Cheers for your help, hope this makes more sense ;)

It seems to me you just need to initialize and print the values... your initialization seems to only add the name, but not the numbers.

something like

football.n = 0;

should initialise the values if done for each one, then just print them in your print function...

cheers marinme 4 your help :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.