在linux虚拟机中怎么用c语言编译输出"hellolinux"。。。求详细过程。。。。

如题所述

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;

}

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2018-02-27
你是说在虚拟机的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 就可以。

本回答被网友采纳
第2个回答  2012-11-20
a.out 是你编译代码以后生成的可执行文件。

./a.out 就可以执行了
第3个回答  2012-11-07
打开终端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输出啊。。。。这个命令就是用在输出吗。。。。

第4个回答  2017-08-27
这是核心代码,哈哈哈
printf("hellolinux");

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网