2014-10-26 65 views
-1

我试图做一个关于打印与他们的长度的顶部和底部边缘的梯形程序。但我无法执行我的代码来查看它是否正常工作。这里是我的代码:错误C2449和错误C2059

#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:(?缺少函数头)发现 '{' 在文件范围内

回答

0

取下int main(void)函数线尾;,这不是一个有效的语法

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

变化

int main(void); 

int main(void) //no semicolon 
相关问题