typedef struct _DListNode
{
struct _DListNode* prev;
struct _DListNode* next;
void* data;
}DListNode;
in gcc :
DListNode *p = NULL;
p = (DListNode*)malloc(sizeof(DListNode));
p->data = (int*)malloc(sizeof(int));
scanf("%d", (int*)p->data);
compile correctly.
in gcc :
DListNode *p = NULL;
p = (DListNode*)malloc(sizeof(DListNode));
(int*)p->data = (int*)malloc(sizeof(int));
scanf("%d", (int*)p->data);
There is a problem on :
(int*)p->data = (int*)malloc(sizeof(int)); -------error: lvalue required as left operand of assignment.
the difference:
scanf("%d", (int*)p->data) ,
(int*)p->data = (int*)malloc(sizeof(int)),
p->data = (int*)malloc(sizeof(int));