#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int value;
struct node *next;
}LLIST;
LLIST *list_add(LLIST **p, int i)
{
if (p == NULL)
return NULL;
LLIST *first = malloc(sizeof(LLIST));
if (first == NULL)
return NULL;
first->value = *first;
*p = first;
first->value = i;
}
int main (int argc, char** argv) {
int i=0;
LLIST *first = NULL;
list_add(&first, 0);
return (EXIT_SUCCESS);
}
给我这样的错误
IntelliSense: a value of type "void *" cannot be used to initialize an entity of type "LLIST *"
在 list_add 的 malloc 行,你能帮我吗???当我输入代码时,没有显示任何错误 intellisense 正在帮助我构建节点代码......但是当编译这个即将到来时......你能帮我解决它吗?
最佳答案
您是否将其编译为 C 代码?在 C++ 中,没有从 void * 到其他指针类型的转换。检查您的文件是否具有 .c 扩展名。
还有,你这里有一个错误:
first->value = *first;
可以想象,您或编译器对此感到困惑。
关于c - Visual Studio 2010 问题中的链表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3360904/