簡體   English   中英

我正在嘗試在 VS 代碼上運行 C,這就是終端上的內容。 我怎樣才能解決這個問題?

[英]I'm trying to run C on VS code and this is what's on terminal. How can I fix this?

這是我運行代碼時在 VS 代碼終端上的樣子。

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\C C++> cd "d:\C C++\" ; if ($?) { g++ TEST.C -o TEST } ; if ($?) { .\TEST }
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main':
C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
PS D:\C C++> 

這是我嘗試運行的簡單程序。

#include<stdio.h>

int main(){
    int age;
    printf("Enter age\n");
    scanf("%d",&age);
    printf("age is %d",age);
    return 0;
}

程序截圖

按照@Gaurav Pathak 的說法保存文件,並檢查您是否設置了編譯器的路徑。 並嘗試gcc a.c -o a.exe一次。 有時代碼運行器會做一些意想不到的事情。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM