安装好虚拟机VMware以及RHEL / CentOS后,就搭建好Linux环境了。这一部分完成在Linux环境下使用C语言和python输出Hello World。
一、C语言实现hello world输出
1. 编辑文件
[root@fishyoung ~]# vi hello.c
注:打开或者创建并打开文件,输入以下内容
# include <stdio.h>
int main(void)
{
printf("hello world!\n");
return 0;
}
2. 编译文件,产生执行文件
[root@fishyoung ~]# rpm -qa | grep gcc
gcc-4.8.5-16.el7.x86_64
注:如果gcc未安装,请用yum方式安装gcc!!!!
[root@fishyoung ~]# gcc hello.c
3. 运行文件
[root@fishyoung ~]# ./a.out
hello world!
二、python实现hello world输出
Linux 7实际上是默认具有python2环境的,Linux 8默认具有python3环境的,所以只需要写hello.py文件进行编译运行即可。
1. 编辑文件
[root@fishyoung ~]# vi hello.py
注:打开或者创建并打开文件,输入以下内容
print ("hello world!\n")
2. 编译运行python文件
[root@fishyoung ~]# python hello.py
hello world!