gpt4 book ai didi

c - 简单的程序无法用 C 语言编译

转载 作者:行者123 更新时间:2023-11-30 18:22:50 24 4
gpt4 key购买 nike

好吧,我立刻就知道这将是一个愚蠢的问题,但我不明白为什么这个简单的 C 程序无法编译。

#include <stdio.h>
#include <stdlib.h>
typdef struct CELL *LIST;
struct CELL {
int element;
LIST next;
};
main() {
struct CELL *value;
printf("Hello, World!");
}

我是 C 编程新手,不是一般的编程,而是 C 语言。我熟悉 Objective-C、Java、Matlab 和其他一些语言,但由于某种原因我无法弄清楚这一点。我正在尝试在 OS X 中使用 GCC 来编译它,如果这有什么不同的话。感谢您的帮助!

我收到的错误消息是

functionTest.c:5: error: expected specifier-qualifier-list before ‘LIST’
functionTest.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’

最佳答案

最重要的是:你拼写错误了 typedef。

然后,至少现在,我们通常会向 main 添加一个返回类型,如下所示:

int main()

此外,main 应该返回退出状态,因此:

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

typedef struct CELL *LIST;

struct CELL {
int element;
LIST next;
};

int main() {
struct CELL *value;
printf("Hello, World!\n");
return 0;
}

关于c - 简单的程序无法用 C 语言编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12877658/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com