我是新來的編碼,我不斷陷入前幾行代碼,我不明白爲什麼。這是我到目前爲止:如何修復「預期的標識符或'('在C編譯?
#include <stdio.h>
#include <cs50.h>
int main(void);
int n;
{
printf("Minute: ");
int n = get_int();
}
我得到這個消息時,我嘗試編譯代碼:?
我做了什麼錯
我是新來的編碼,我不斷陷入前幾行代碼,我不明白爲什麼。這是我到目前爲止:如何修復「預期的標識符或'('在C編譯?
#include <stdio.h>
#include <cs50.h>
int main(void);
int n;
{
printf("Minute: ");
int n = get_int();
}
我得到這個消息時,我嘗試編譯代碼:?
我做了什麼錯
你試圖調用的主要功能你應該Ø只限定它。它將在程序執行時被調用(它是「入口點」)。
要定義它,移除分號後 INT主(無效)
還可以刪除這一空白關鍵字
然後移動該行下來, INT N的;和後面的{
此外,你聲明n變量兩次。修復第一個錯誤後,編譯器會抱怨這個錯誤。然後刪除其中一個聲明。
您應該刪除int main(void)後面的分號,並在大括號內移動n的變量聲明。以下是正確的代碼。
#include <stdio.h>
#include <cs50.h>
int main(void)
{
int n;
printf("Minute: ");
int n = get_int();
}