Reputation: 3652
Seeing this struct
typedef struct Node{
void *data;
int pos;
struct Node *prev;
struct Node *next;
}*lptr;
I wonder why the typedef of Node
is *lptr
and not lptr
.
What difference does the pointer make?
Upvotes: 0
Views: 115
Reputation: 10184
Because the definition (the typedef) is to a pointer type. Removing it makes lptr of type Node, * makes it a pointer to a Node.
Upvotes: 1
Reputation: 726569
Although it is common to have two typedef
s - one for the struct
to avoid the tag, and one for the struct
pointer to avoid the asterisk, like this
typedef struct Node{
void *data;
int pos;
struct Node *prev;
struct Node *next;
} Node;
typedef Node* lptr;
if the authors want to avoid writing an asterisk after lptr
or Node
, they could certainly typedef
a pointer to struct Node
.
Upvotes: 3
Reputation: 33273
The typedef is for a pointer type.
lptr
is the type struct Node*
Upvotes: 1