mac下用vim编写程序
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可執(zhí)行文件
????????輸入下面命令,不要忘記是g++,不是gcc
???????
? ? g++ test.cpp -o test
????????如果出現(xiàn)下面報錯
? ? bogon:Music a1111$ g++ test.cpp -o test
? ? xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the di ? ?alog to download the command line developer tools.
????????mac會自動安裝程序,我們需要耐心等待就行
???????5)執(zhí)行test文件
?????????輸入下面命令
?????????
? ? ./test
? ? ? ??
?????????
??????????
?
總結(jié)
以上是生活随笔為你收集整理的mac下用vim编写程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Date类型JSONArray.from
- 下一篇: mac下用vs code编写c++程序