[英]Output is not shown when trying to run C program
當我嘗試運行該程序時,終端不顯示任何內容。
這是程序:
/* Print a message on the screen*/
#include <stdio.h>
int main()
{
printf("Hello World.\n");
return 0;
}
我做錯什么了嗎?
- 編輯 -
我的防病毒軟件阻止了該程序的執行。
在字符串末尾添加換行符(或使用puts
):
/* Print out a message on the screen*/
#include <stdio.h>
main()
{
printf("Hello World.\n");
return 0;
}
通常,編譯器會優化對puts("Hello, World.")
printf
調用。
還建議將main
聲明為int
(使用int main() ...
)。
在C語言中定義函數時,需要指定返回類型。 因此,您的main函數必須聲明為int main()
(因為它返回一個整數)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.