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
