Live Input Output (Competitive Programming) setup in VS CODE for C/C++ (WINDOWS)
Published: 2020-05-22 17:44:14

## How to install and setup vs code for competitive programming with c/c++ for Windows Users

###  install  vs code

- Download vs code : [Link](https://­code.visualstudio.com)
- Install in your pc

### Setup environment for c/c++

- install mingw : [link](https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/)

- In you pc search for **system environment**

![search system enbironment](https://github.com/jspw/VS-Code-Config/raw/master/images/search%20system%20enbironment.png)

- go to **Environment variables** 

![Environment variables](https://github.com/jspw/VS-Code-Config/raw/master/images/environment%20variable.png)

- Go to **system varibale** and **click on path**

![system varibale](https://github.com/jspw/VS-Code-Config/raw/master/images/path%20edit%20and%20add%20new.png)

- click edit

- select new 

- paste the link where you mingw bin folder . for me it is `C:\MinGW\bin` 
    - find it there
    
- select ok ok for everything

### Install git 
- download link [Link](https://git-scm.com/download/win)

Then 

- Open Vs code

- Open your coding folder `file->open folder`

- press `ctrl+~` and the terminal will be opened at the bottom

![terminal](https://github.com/jspw/VS-Code-Config/raw/master/images/vs%20code%20terminal.png)

- if in the terminal u find that its **cmd** or **powershell** then click  on **cmd/powershell** and select '`set default sell`' and select `git`

- - Now click on the delete icon and  press `ctrl+~` and its saying your shell is bash!

- if still bash no showing then close vs code and open vs code again

![](https://github.com/jspw/VS-Code-Config/raw/master/images/vs%20code%20terminal.png)


### Run a programme for testing :
- create a file hello.cpp
- write code to print hello
- in terminal use the command 

        g++ hello.cpp -o test && ./test
        
        
- If you find `hello` then congrats
- if saying g++ not found then try to close vs code and then oepn vs code again.

### Setup Vs Code

- Clik on terminal (At the top)
![Top bar](https://github.com/jspw/VS-Code-Config/raw/master/images/top_bar.png)

- select configure task
- select create task.json from template 
- select other and new task.json file will be created
- now copy and paste the my `task(windows).json` {[link is here](https://github.com/jspw/VS-Code-Config/blob/master/Config-Files/C%26C%2B%2B/Windows/tasks.json)}   file into your `task.json` file
- done

More things to do :
Note : **You just need to do these things only for the first time of your workspace!**
- Split screen in 3 sections 
![Split Screen](https://github.com/jspw/VS-Code-Config/raw/master/images/split%20options.png)
  - split the main section in right (right mouse click on the .cpp file and u will get the split options)
  - then split the right into down (same as above)
- create a file named `input.txt`
- create a file named `output.txt`
- open input.txt into the upper right section
- open output.txt into the lower right section

#### This will be the final look of your vs code 

![Final Look](https://dev-to-uploads.s3.amazonaws.com/i/5now5k1orkmc6nhwq83w.png)


## Now create a folder and create your file .cpp inside the folder and give inputs in input.txt and press `Ctrl+Shift+b` and your output will be in the output.txt file

**Note :** **Don't keep the cpp file in the base folder**. I mean you have to **create one or more folders** in the **base folder** (Base folder means **where you opened your vs code** or you can say **vs code wrokspace** folder).and the input and output file should be in the base folder.

##### Folders should be like this or similer :
![VS CODE Folders](https://github.com/jspw/VS-Code-Config/raw/master/images/folders.png)

##### Not This

![](https://github.com/jspw/VS-Code-Config/raw/master/images/dont.png)


## Press `Ctrl+Shift+b` and your output will be in the output.txt file 

# Happy coding :3