您的位置:首页 > 其它

ubuntu使用vim编译第一个C程序

2017-06-29 10:37 351 查看
1.1 打开控制台:使用快捷键 Ctrl + Alt + T;

1.2 安装vim:输入 sudo apt-get install vim;

1.3 安装gcc:输入 sudo apt-get install g++。

2.编写hello.c源代码

2.1 新建文件名为hello.c的源文件:输入vim hello.c;

2.2 键入i 进入insert模式(即编辑输入模式),写入如下经典代码:

//the first program hello.c
#include<stdio.h>
int main(void)

{
printf("Hello, world!\n");

return 0;

}
2.3 输入完成后,Esc 回到normal模式,键入:wq 保存退出vim。

3.编译hello.c

在终端执行  g++ hello.c -o hello 编译。

4.运行程序hello

./hello 就看到结果:

Hello,world!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐