c - Visual Studio 2010 问题中的链表

标签 c visual-studio-2010

#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/

相关文章:

c# - 为什么我不能在 VS 2010 中使用布局工具栏上的增加/减少水平间距按钮?

.net - 如何使 vs2010 在文件末尾自动生成方法 stub

c - 在C中删除结构内部的字符串

转换c指针类型

c# - 界面无法更新

visual-studio-2010 - Visual Studio 正在将我的 Azure Web 角色设置为 127.255.0.0 :82 instead of 127. 0.0.1:80

c - Unix信号量问题

c++ - 为 C 库创建 Haxe hxcpp 包装器

c - Stm32L151RCxxx USART挂起问题,同时基于中断的TX/RX

c# - 带有 MVC 4 的 VS 2010 中关于缺少对 Microsoft.CSharp.dll 和 System.Core.dll 的引用的警告消息