iT邦幫忙

0

[Visual Studio Code macOS] C 語言語法沒有錯誤,無法輸出指令

最近剛開始學習寫程式,因為本身用MAC,使用微軟的VSCode為平台。
發現有些C語言的指令無法跑出來,會一直顯示[Running],想詢問是哪裡有錯誤?

https://ithelp.ithome.com.tw/upload/images/20210312/20135864svCsRLVDVJ.png

不好意思,第一次發問,也發問的不太詳細,希望有使用VScode的前輩能夠指導我一下,謝謝各位!

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

1
海綿寶寶
iT邦大神 1 級 ‧ 2021-03-12 09:25:29
最佳解答

如果你找得到 launch.json 的話
把裡面的 externalConsole 設為 true 再試試看

參考資料來源

其實沒有錯誤
一直 Running 是正常的
因為你寫了那個 scanf
程式在「等」你輸入資料()
/images/emoticon/emoticon13.gif

Kodaiyen iT邦新手 5 級 ‧ 2021-03-12 12:48:36 檢舉

非常感謝你,我用終端機輸出之後就正常了,感謝解惑!

有空時請在所有回答中選一個
「選為最佳解答」以進行結案動作

0
rogeryao
iT邦超人 8 級 ‧ 2021-03-12 01:08:40
#include <stdio.h>

int main(void) {
    char buf[50];

    printf("請輸入 1 到 5 的字元:");
    scanf_s("%[1-5]", buf,6);
    printf("輸入的字元為 %s\n", buf);

    return 0;
}
#include <stdio.h>

int main(void) {
    int input;

    printf("請輸入數字:");
    scanf_s("%d", &input);

    printf("你輸入的數字:%d\n", input);

    return 0;
}
Kodaiyen iT邦新手 5 級 ‧ 2021-03-12 12:49:12 檢舉

感謝你的解惑,我再來試試看!

我要發表回答

立即登入回答