新手开始编译打开windows power shell输入cd D:\c-primer <将在低权限编译>notepad hello.c开始编译 <“;”经常容易忘记>

#include <stdio.h>int main(){ printf("Hello,world!"); return 0;}

输出文件

gcc hello.c -o hello.exe <其中“-o”为“指定输出文件(名)”>

若无反应运行程序

./hello

如何捕捉程序运行的瞬间(这个程序运行极快)查看文件 cat .\hello.c (然后出现该.c文件代码) <键盘↑↓键可以切换已输入指令>在.c文件中输入一个死循环

for(;;);

<输入control+c停止运行程序>

#include <stdio.h>int main(){ char buffer[40] printf("input your name: "); fgets(buffer, [40], stdin); printf(“your name is %s",buffer); return 0;}


计算圆面积#include <stdio.h>int main(){ float radius; radius = 2; float pi = 3.14159; float s = pi * radius * radius; printf("The area of a circle with a radius of %f is %f\n",radius, s) return 0;}
