第一步:在桌面創建文件夾 hello,並在hello文件夾中創建helloworld.c文件並編輯。
mkdir hello
touch helloworld.c
vim helloworld.c
第二步:在helloworld.c文件中寫入代碼
#include <stdio.h>
int main(){
printf("Hello World!");
return 0
}
第三步:用gcc編譯
gcc -Wall helloworld.c -o helloworld//-Wall 編譯後顯示所有警告 ,-o 是輸出參數,輸出名字的參數,如果不加-o 參數。命令:gcc helloworld.c 則會生成a.out的可執行文件。
第四步:運行
./helloworld