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!
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!
相关文章推荐
- Ubuntu 下使用Eclipse编译、调试嵌入式程序的方法(下)
- MAC中使用Vim和GCC编译C程序
- Linux操作系统的简单指令及如何使用vim编写一个程序,然后使用gcc查看【预处理】、【编译】、【汇编】、【链接】各阶段文件的内容。
- Ubuntu16.04.2 LTS下使用编译安装程序(使用configure、make、 make install)
- ubuntu 10.04 编译安装 vim 7.3, 解决 vim 不能使用系统剪贴板问题
- windows下使用IDA远程调试linux(ubuntu)下编译的程序
- Ubuntu下编译第一个C程序的成功运行
- ubuntu使用技巧——如何编译C++和C语言的使用程序
- windows下使用Eclipse编译执行MapReduce程序 Hadoop2.6.0/Ubuntu
- Ubuntu 下使用Eclipse编译、调试嵌入式程序的方法(中)
- 使用Eclipse编译运行MapReduce程序 Hadoop2.7.1/Ubuntu
- 编译和使用apue.3e源码并实现第一个ls.c程序
- Ubuntu 16.04使用NASM编译时用ld链接程序出现:i386 架构于输入文件 sandbox.o 与 i386:x86-64 输出不兼容(I386 architecture in the input file sandbox.o is not compatible with i386: x86-64 output)
- Ubuntu下使用Eclipse编译、调试嵌入式程序的方法(上)
- Ubuntu下 在终端使用 qmake 编译 Qt widgets程序
- 使用Eclipse编译运行MapReduce程序 Hadoop2.6.0_Ubuntu/CentOS
- ubuntu下使用eclipse调用libpcap库编写一个小程序时出的错误:pcap.h没有参与编译
- Ubuntu系统下的Hadoop集群(4)_使用Eclipse编译运行MapReduce程序
- OC---第一个OC程序(使用GNUstep的shell编译执行)
- [Linux]在ubuntu系统下编译运行c程序并使用makefile管理项目