在Linux环境下运行C程序

准备工作
安装编译器
在Linux系统中,C程序的编译主要依赖于GCC(GNU Compiler Collection)编译器,您可以通过以下命令安装GCC:
sudo apt-get install build-essential
编写C程序
使用文本编辑器(如Vim、Emacs或gedit)编写C程序,以下是一个简单的“Hello, World!”程序示例:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
将上述代码保存为hello.c。

编译C程序
打开终端
在Linux系统中,打开终端有多种方法,如按下Ctrl + Alt + T或点击任务栏的终端图标。
进入C程序所在的目录
使用cd命令进入保存C程序的目录。
cd /path/to/your/c/program
编译C程序

使用gcc命令编译C程序,以下命令将编译hello.c文件,并生成可执行文件hello:
gcc -o hello hello.c
检查编译结果
如果编译成功,终端将显示以下信息:
gcc: hello.c:1:1: warning: implicit declaration of function 'main'
gcc: hello.c:1:1: note: declared at hello.c:1:1
gcc: hello.c: In function 'main':
gcc: hello.c:3:5: warning: 'printf' is deprecated
gcc: hello.c:3:5: note: this format specifier is deprecated
gcc: hello.c:3:5: note: please use 'printf("%s", "Hello, World!\n")' instead
gcc: hello.c:3:5: note: please include <stdio.h> for the declaration of 'printf'
gcc: hello.c:3:5: note: please use the ISO C99 feature "ISO C11 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C99 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello.c:3:5: note: please use the ISO C feature "ISO C90 6.5.2.1: format specifiers" if you intended to declare 'printf' as a macro
gcc: hello