c - 错误 C2449 和错误 C2059

标签 c

我正在尝试编写一个关于打印梯形及其顶部和底部边缘长度的程序。但我无法执行我的代码来查看它是否有效。这是我的代码:

#include <stdio.h>

int main(void);
{
    int top, bot, a, b;

    printf("Please enter the length of top:");
     scanf("%d", &top);
    printf("Please enter the length of bottom:");
     scanf("%d", &bot);

for(a = top; a < bot; a++) {
    for(b = top; b < a+1; b++) {
        printf("* ");}
    printf("\n");}
 return 0;
}

这是我的错误文本: 错误 C2059:语法错误:'}'
错误 C2449:在文件范围内找到“{”(缺少函数头?)

最佳答案

int main(void) 函数行中删除尾随的 ;,这不是有效的语法

int main(void) // this is wrong here: ';'
{
  ...

关于c - 错误 C2449 和错误 C2059,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26573630/

相关文章:

c - 如何创建一个指向另一个链表的链表?

python - scipy.weave.inline 的语法错误

C程序可以不用main函数吗?

c - 取malloc()、realloc()和free()的地址是否可移植?

c++ - 有没有办法使用 SWIG 将不同的数组类型从 python 传递到 c++?

c - X86 汇编 - 处理 IDIV 指令

c++ - 数组变量中有更多变量还是多一维?

C中的计算包含

c - 按位操作 : After a series of consecutive bits, 将最左边的不同位传播到右边

c - C中每行具有不同大小的二维数组