2014-10-26 249 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 
相關問題