第一章:Hello World 講解
這是我們寫在《環境搭建》那一章的 “hello world” 程式,
#include <stdio.h>
int main()
{
printf("Hello World.\n");
return 0;
}
先看看整體結構,
先是一個頭檔案包含陳述句,#include <stdio.h>,為什么要包含檔案,因為后面用到了printf函式,printf函式的宣告在 stdio.h檔案中,如果不包含的話,會警告
helloworld.c: In function ‘main’:
helloworld.c:4:5: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
printf("Hello World.\n");
我們現在是個小程式,所有的代碼都在一個檔案中,當專案大了的時候,很多函式會放到不同的檔案中,這個時候就要包含函式宣告的頭檔案,方便代碼的管理,
接著是一個函式 main,main函式中兩條陳述句, printf(“Hello World.\n”);和return 0;,左大括號和右大括號,說明了main函式的作用域,
每個C程式都有一個入口函式,默認是main 函式,當然我們也可以通過編譯器編譯的時候進行更改,先看這兩條
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/260096.html
標籤:其他
上一篇:論建立實時大資料平臺
