__frank__ said:
I'm referring to linked list.
In some codes I find:
/* 1 */
newNode=malloc(sizeof (struct* node));
This function allocates only enough space for the pointer of the node.
Is this what you want, or do you want to allocate enough space for the
entire node?
in other ones, instead I find:
/* 2 */
newNode (list_type) malloc (sizeof (struct* node));
This is not grammatically correct. It would be much better if you could
actually copy and paste the relevant sections of code. Otherwise we're
just guessing.
As mentioned previously in this newsgroup (read back up to a couple of
weeks), you will find many mentions about your question. Don't typecast
the result of malloc(). See the C newsgroup faq and previous posts about
why.
From what we have, the first one is better. But with no code posted,
both could be wrong.
It would be most helpful if you could post a minimal sample in C that
can be compiled (that you have also personally compiled) that
demonstrates what you are asking for.