View Single Post
Old 12-04-2006, 07:28 AM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,721
redhead is on a distinguished road
Quote:
first, in struct employee declaration, you have nested struct pointer def, is that legal?
Yes it is perfect legal, it's just a pointer and since you'd declared it as struct name { items;}; instead of typedef struct { items;}name; you are able to reference the name of the struct within the struct eventho it is not yet completely declared.
Quote:
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?
The declaration of the print_list() is correct aswell, since theres no definition of what emp1 within the function arg list, you declare it emidiate after, before the body of the function, thus the struct employee *emp1; emidiately following the function definition, it's K&R style definitions..
Considder this
Code:
redhead@fenris{56} ~> cat test.c
#include <stdio.h>

int blah(s) const char* s;
{
        printf("%s\n", s);
        return 0;
}

int main()
{
        blah("this is a test");
        return 0;
}
redhead@fenris{57} ~> gcc -Wall -ansi test.c
redhead@fenris{58} ~> ./a.out
this is a test
redhead@fenris{59} ~>
Quote:
third, tmp = tmp->next, struct pointer point to another struct pointer?
No, not if you follow the scheme of the function, tmp is pointing to the parsed argument emp1 to the function, or just using tmp as a temporary placeholder so teh parsed argument wont be messed up.
Quote:
teach me if i said something wrong!
I belive I just did
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote