Linux gcc编译命令
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
编写一个C程序
1.用文本文件编写代码
用 touch 命令:“touch 文件名” 可以创建一个文件(比如 touch hello.c),如下图:
在命令行输入 touch hello.c ,就在文件夹中创建了一个hello.c文件,打开文件编写我们著名的 “hello world ” 并保存
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("Hello,World\n");
return 0;
}
2.编译文件
现在我们已经写好了一个C代码。在命令行使用命令:gcc -o 指定文件名 文件(gcc -o hello hello.c)
这样我们就编译好了这个代码,重新打开文件夹(一般是home)会发现多了一个hello文件
然后我们在命令行输入: ./文件名(./hello) 就能得到输出(“.” 代表当前目录),如下所示
值得注意的是,
上面 的 -o name 选项是告诉编译器可执行程序的名字,就是后面生成的hello文件,如果你忘记提这个,那么编译器会把程序放在一个名为:a.out 的文件里(a.out的含义是seeember output,即汇编输出)。如果你确信编译了一个程序但又找不到它,别忘了看看有没有a.out文件。
例子如下:
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:4 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献1条内容
所有评论(0)