1️⃣打开终端后,进入我的目录路径下,输入命令
cd /Users/zhangsf/code/c
2️⃣新建一个.c文件(用来编写代码),输入命令:
1 #include<stdio.h>
2 int main(){
3 printf("hello\n");
4 return 0;
5 }
输入完毕后,保存并退出,先按“esc”键,然后输入:wq即可;
3️⃣编译,输入命令gcc helloword.c,此时如果电脑上没有编译工具,点击安装即可;若程序有错误,则再次进入步骤2修改程序;若无错则进入下一步骤;
4️⃣运行,输入./a.out helloworld.c运行出结果。