首页 > 虚拟机

linux虚拟机运行c程序命令

步骤 命令 说明 1. 编译 C 程序 gcc -o 文件名.out 文件名.c 将 C 代码文件(文件名.c)编译成可执行文件(文件名.out)。 2. 运行 C 程序 ./文件名.out 执行编译后的可执行文件。
示例:
假设你有一个名为 "hello.c" 的 C 代码文件,其内容为:
c
include
int main() {
printf("Hello, world!\n");
return 0;
}
编译和运行步骤:
1. 编译: gcc -o hello.out hello.c
2. 运行: ./hello.out
这将输出:
Hello, world!

返回顶部