c - Main.c :3:9: error: expected ‘=’ , ‘,’ 、 ‘;’ 、 ‘asm’ 或 ‘__attribute__’ 位于 ‘{’ token 之前

标签 c

在这个简单的程序中,要查找数字是偶数还是奇数,它会不断出现错误 Main.c:3:9: error: Expected '=', ',', ';', 'asm' or '< “{”标记之前的“strong>属性”。请帮忙。

#include<stdio.h>
int main{
int n;
  scanf("%d",&n);

  if(n%2==0)
    printf("%d is an even number",n);

  else
    printf("%d is an odd number",n);
return 0;
}

最佳答案

由于您在声明 main 时省略了 (),编译器认为您正在声明一个变量,因此错误消息中表达了困惑。

关于c - Main.c :3:9: error: expected ‘=’ , ‘,’ 、 ‘;’ 、 ‘asm’ 或 ‘__attribute__’ 位于 ‘{’ token 之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55419322/

相关文章:

c - 在循环中实现随机数组以获得总和

c - Main 中函数类型之前的预期表达式

c - 如何在多个模块中处理静态全局变量?

c - 当程序多次要求输入时使用文件作为程序输入

c - ioperm 无需 root 权限即可工作

c - 在 C 中,ARM 编译器将如何优化此结构?

C函数调用作为测试条件

c - 请解释输出

c - C 输出背后的逻辑

c - 在c、位域结构或宏集中定义Flag并获取