0

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;
      and
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.

3
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by Adak
0
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.

0

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

0

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)?

1

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.