1、编译生成的执行程序,例:gcc -W hello.c -o hello
2、执行生成的执行程序,例: chmod +x hello; ./hello
3、编写源代码:
#include
int main()
{
printf("hellolinux\r\n");
return 0;
}
扩展资料
在linux虚拟机中用c语言编译输出"Hello world"
#include
int main()
{
printf( “Hello world!/n” );
return 0;
}
你是说在虚拟机的linux系统下写个C语言程序吗。
用gcc编译器。源文件为main.c的话,在shell终端下,gcc -c main.c -o hellolinux 编译就行。
运行./hellolinux 就可以。
main.c
#include
#include
int main()
{
printf("hellolinux\n");
return 0;
}
a.out 是你编译代码以后生成的可执行文件。
./a.out 就可以执行了
打开终端vim hellolinux.c 按i进入编辑,输入下列代码,保存(按esc之后:wq),gcc hellolinux.c之后输入./a.out
#include
int main()
{
printf("hellolinux!");
return;
}
还必须给hellolinux.c这个文件可执行的权限
chmod +x hellolinux.c
这是核心代码,哈哈哈
printf("hellolinux");