帮忙改一个小错误

来源:百度知道 编辑:UC知道 时间:2024/05/26 13:03:08
#ifndef _list_H

struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;

#endif /*_LIST_H*/

#include <stdio.h>
#include <stdlib.h>

struct Node
{
int Element;
Position Next;
};

List MakeEmpty(List L)
{
L = malloc (sizeof(struct Node));
}

.cpp(21) : error C2440: '=' : cannot convert from 'void *' to 'struct Node *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
解释一下为什么
谢谢

#ifndef _list_H

struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;

#endif /*_LIST_H*/

#include <stdio.h>
#include <stdlib.h>

struct Node
{
int Element;
Position Next;
};

List MakeEmpty(List L)
{
return L =(struct Node*) malloc (sizeof(struct Node));
}
void main()
{

}