Tvally 2022-09-24 19:03 采纳率: 64.7%
浏览 813

C语言未定义标识符及各种错误

问题遇到的现象和发生背景

VS2022下编译不通过,NULL显示的是未定义标识符,已经定义的结构体显示的是未定义标识符,各种错误都有

用代码块功能插入代码,请勿粘贴截图
#include <stdio.h>
#include <stdlib.h>


struct Node
{
    int data;
    struct Node* next; // C++中只需要写Node*
};
struct Node* head;
void Insert(int x)
{
    struct Node* temp = (Node*)malloc(sizeof(struct Node));
    temp->data = x;
    temp->next = head;
    head = temp;
}
void Print()
{
    struct Node* temp = head;
    printf("List is:");
    while (temp != NULL)
    {
        printf(" %d", temp->next);
        temp = temp->next;
    }
    printf("\n");
}
int main(void)
{
    int n, x;
    head = NULL;
    printf("How many numbers?\n");
    
    scanf("%d\n", &n);
    for (int i = 0; i < n; i++)
    {
        printf("Enter the number:\n");
        scanf("%d", &x);
        Insert(x);
        Print(x);
    }

    return 0;
}

运行结果及报错内容

img

  • 写回答

2条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-09-24 21:02
    关注
    评论

报告相同问题?

问题事件

  • 创建了问题 9月24日

悬赏问题

  • ¥15 关于#python#的问题:我知道这个问题对你们来说肯定so easy
  • ¥15 wpf datagrid如何实现多层表头
  • ¥15 为啥画版图在Run DRC会出现Connect Error?可我Calibre的hostname和计算机的hostname已经设置成一样的了。
  • ¥20 网站后台使用极速模式非常的卡
  • ¥20 Keil uVision5创建project没反应
  • ¥15 mmseqs内存报错
  • ¥15 vika文档如何与obsidian同步
  • ¥15 华为手机相册里面的照片能够替换成自己想要的照片吗?
  • ¥15 陆空双模式无人机飞控设置
  • ¥15 sentaurus lithography