---
# System prepended metadata

title: '**Programming with Visual Studio Code**'
tags: [compiler VSC Ｗith winsock]

---

###### tags: `compiler VSC Ｗith winsock`

# **Programming with Visual Studio Code**
1. 編譯聯網程式時:
    * 若是使用vs code編輯再編譯時記得呼叫連結器(-l)呼叫(ws2_32)如下
     ![](https://i.imgur.com/6G8xjIY.png)
     ![](https://i.imgur.com/3D6fV63.png)
2. 多個cpp檔:
    1. include進入主程式
     ![](https://i.imgur.com/mevNpNu.png)
    2. 在G++後串聯多個cpp檔案

# **How to do "Start Button" in VSC?**
1. In Marketplace(At last in left tool bar) to download "code Runner".
    ![](https://i.imgur.com/ksujxu6.png)
     
2. When you downloaded, you should see a new button added to VSC.
    ![](https://i.imgur.com/7VJzN9x.png)
    
3. Now you get a Strat Button,
    but it is not perfect yet, we should setting and use it to compiler winsock ".cpp"
    1. If you Don't setting it. you can't Compiler winsock ".cpp"
    2. First: Go to the Marketplace find code Runner and click set button.
    ![](https://i.imgur.com/89C5ugu.png)
    3. Choose Extension setting(擴充設定).
    4. Choose setting json.
    ![](https://i.imgur.com/02qxPRI.png)
    5. Add at following text in to ".json":
    ```json
    "code-runner.executorMap": {
        "cpp": "cd $dir && g++ -std=c++14 *.cpp  -o  $fileNameWithoutExt.exe  -lws2_32 && $dir$fileNameWithoutExt",
    },
    ```
    6. Note that this paragraph of text can compile all files in the folder.      So you should put one project in one folder.     Or revise code Runner's setting".json"
        * For example: If you want to compile one ".cpp" you can revise ".json" at following text.
    ```json
     "code-runner.executorMap": {
        "cpp": "cd $dir && g++ $fileNameWithoutExt*.cpp  -o  $fileNameWithoutExt.exe  -lws2_32 && $dir$fileNameWithoutExt",
    },
    ```
# **Why use codeRunner Run .EXE have garbled?**
*    **Is like ↓**
    ![](https://i.imgur.com/CTWlZeO.png)
*  **How to solve?**
    I have a good solution to share with everyone.
    1. Open the codeRunner setting, Search "run in terminal"  and check this.
    ![](https://i.imgur.com/4zSKFKb.png)
    *  **OR add following text in to ".json"**
        ![](https://i.imgur.com/I7wku0v.png)

    2. Not only will there be no garbled characters, and you can enter to terminal.

# **Why use VSC to coding**
1. You can compile if you have a folder and code(Manage the project yourself)
2. Free
3. Good for learners and student
4. **我亂打的別信**

-lsw2_32