mac环境下分别用vim和Xcode运行C++(hello word)程序

212 阅读1分钟

1、用vim写第一个C++程序

       1)  打开mac终端        2) 用vim新建一个test.cpp文件

    vim test.cpp

       3) 写hello word代码

         输入插入命令 

    i

         写入代码

    #include<iostream>

    using namespace std;

    int main() {
        cout<<"hello word"<<endl;
        return 0;
    }

        保存代码,输入下面命令 

    :x

       4)用g++编译成test可执行文件

        输入下面命令,不要忘记是g++,不是gcc

       

    g++ test.cpp -o test

        如果出现下面报错

    bogon:Music