如题所述
第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;
}追问
用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 就可以执行了
./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追问
#include<stdio.h>
int main()
{
printf("hellolinux!");
return;
}
还必须给hellolinux.c这个文件可执行的权限
chmod +x hellolinux.c追问
为什么用./a.out输出啊。。。。这个命令就是用在输出吗。。。。
第4个回答 2017-08-27
这是核心代码,哈哈哈
printf("hellolinux");
printf("hellolinux");