发布网友
共5个回答
热心网友
1、编译生成的执行程序,例:gcc -W hello.c -o hello
2、执行生成的执行程序,例: chmod +x hello; ./hello
3、编写源代码:
#include <stdio.h>
int main()
{
printf("hellolinux\r\n");
return 0;
}
扩展资料
在linux虚拟机中用c语言编译输出"Hello world"
#include <stdio.h>
int main()
{
printf( “Hello world!/n” );
return 0;
}
热心网友
你是说在虚拟机的linux系统下写个C语言程序吗。
用gcc编译器。源文件为main.c的话,在shell终端下,gcc -c main.c -o hellolinux 编译就行。
运行./hellolinux 就可以。
main.c
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("hellolinux\n");
return 0;
}追问为什么用./a.out输出啊。。。。这个命令就是用在输出吗。。。。
追答gcc编译程序成可执行文件时,如果没有指定可执行文件名,即没有-o参数 后面带执行文件,就默认把可执行文件输出为a.out。 所以用./a.out执行。
gcc -c main.c -o hellolinux 运行./hellolinux 就可以。
热心网友
a.out 是你编译代码以后生成的可执行文件。
./a.out 就可以执行了
热心网友
打开终端vim hellolinux.c 按i进入编辑,输入下列代码,保存(按esc之后:wq),gcc hellolinux.c之后输入./a.out
#include<stdio.h>
int main()
{
printf("hellolinux!");
return;
}
还必须给hellolinux.c这个文件可执行的权限
chmod +x hellolinux.c追问为什么用./a.out输出啊。。。。这个命令就是用在输出吗。。。。
热心网友
这是核心代码,哈哈哈
printf("hellolinux");