View Single Post
Old 12-03-2006, 08:49 PM   #6 (permalink)
albtross
Recruit
 
Join Date: Nov 2006
Posts: 9
albtross is on a distinguished road
Quote:
Originally Posted by Blondie View Post

struct employee
{
char name[20];
long id_number;
float wage;
float hours;
float overtime;
float gross;

struct employee *next;
};
void print_list(emp1)
struct employee *emp1;
{
struct employee *tmp;
int i = 0;
for(tmp = emp1; tmp ; tmp = tmp->next)
{
i++;
printf("Employee ID: %6d, Wage: %8.2f\n",tmp->id_number,
tmp->wage);
}

printf("\n\nTotal Number of Employees = %d\n", i);

}


basically, in this program, you are playing with pointers, i am not sure about what i am saying, but anyway just expressing my ideas, i can learn from it too.
first, in struct employee declaration, you have nested struct pointer def, is that legal?
second, void print_list(emp1) i assume it's a function not a prototype, then you declare another two pointer struct inside it, aren't you supposed to put them inside block? also, you are passing emp1 as an argument, and then you declare it again.
third, tmp = tmp->next, struct pointer point to another struct pointer?
teach me if i said something wrong!
albtross is offline   Reply With Quote