linux下使用vim编写第一个c程序

一.安装

在终端下依次输入以下两个命令(注意:要是root用户,否则没有权限)

yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
yum -y install wget httpd-tools vim

二.使用

例子:helloworld程序:输出helloworld

(1)创建名为helloworld.c文件

vim helloworld.c

(2)进入文件之后,按‘i'建后开始编写代码:

#include <stdio.h>
int main()
{
printf("hello world!\n");
return 0;
}

(3)保存退出,按"ESC"这个键,然后输入wq!

(4)退出之后在终端输入:编译helloworld.c命令

gcc helloworld.c
执行命令:
./a.out

(5)最后的结果:

 

posted @ 2020-03-14 23:49  saaas  阅读(336)  评论(0)    收藏  举报