Hello , Please what does the second typedef statement do,

struct listnode{
char data;
struct listnode *nextPtr;

typedef struct listnode Listnode;
typedef ListNode *ListNodePtr;

what is the difference between

ListNodePtr *sPtr;
ListNodePtr startPtr;

Please explain what the second Line of Code would do please

startPtr = NULL;
ListNodePtr *sPtr = &startPtr

Edited by WaltP: Fixed CODE Tags -- if your post doesn't look correct, use the EDIT button.

6 Years
Discussion Span
Last Post by Adak
typedef ListNode *ListNodePtr;

means you are making an alias for "ListNode*" as "ListNodePtr".
So when you declare avariable of type "ListNodePtr" it will mean you are declaring a variable of type "ListNode*".

ListNodePtr *sPtr;
ListNodePtr startPtr;

You will get the difference once you replace the alias name with the original data types.

ListNodePtr *sPtr = &startPtr

Expand the alias for "ListNodePtr" you will know what it is doing.


does declaring a variable of type ListNodePtr or ListNode* make the variable a pointer?


sorry for all the ridiculous questions , but i really want to clear my doubts and get this right .
if declaring a variable of type ListNodePtr makes it a pointer, then declaring it with type ListNodePtr* makes it ?(a double pointer)?


You have been given the same answers in two different C forums, I hope that's enough cross posting on this subject.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.