Ubuntu运行C++程序

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chekongfu/article/details/83998399

1 使用touch helloworld.cpp创建一个名为helloworld的c++文件

2 用ls查看创建文件是否存在

3 用vi helloworld.cpp打开文件进行编辑,保持

#include<iostream>
using namespace std;

int main(){

    cout<<"hello world"<<endl;
    return 0;
}

4 用g++ helloworld.cpp -o helloworld运行该程序,结果保存在helloworld文件中

5 用./helloworld查看运行结果。
在这里插入图片描述

ps:Linux下编译C语言用的是gcc命令,而编译C++程序则用的是g++命令, 要特别注意。

猜你喜欢

转载自blog.csdn.net/chekongfu/article/details/83998399