DEV Community

Live Input Output (Competitive Programming) setup in VS CODE for C/C++ (WINDOWS)

5hfT on May 22, 2020

How to install and setup vs code for competitive programming with c/c++ for Windows Users install vs code Download vs code ...
Collapse
 
viissgg profile image
Vijay •

Hey. Thanks for this nice guidelines. I'm getting below error. Can you please help ?

> Executing task:  cp d:\extra\cpp\hello.cpp D:\extra\cpp && g++ hello.cpp -o test.out && ./test.out < input.txt > output.txt && rm *out && rm hello.cpp <

cp: cannot stat 'd:extracpphello.cpp': No such file or directory
The terminal process "C:\Program Files\Git\bin\bash.exe '-c', ' cp d:\extra\cpp\hello.cpp D:\extra\cpp && g++ hello.cpp -o test.out && ./test.out < input.txt > output.txt && rm *out && rm hello.cpp'" failed to launch (exit code: 1).

Terminal will be reused by tasks, press any key to close it.
Enter fullscreen mode Exit fullscreen mode
Collapse
 
mh_shifat profile image
5hfT •

Recently i have added some changes for windows hope this will help. Please check this out

github.com/jspw/VS-Code-Config/iss...

Collapse
 
viissgg profile image
Vijay •

Hmm. I moved the cpp file in there own folder as mentioned in the link. But still no luck :(

Thread Thread
 
mh_shifat profile image
5hfT •

give me a ss of your base folder

Thread Thread
 
viissgg profile image
Vijay •
Thread Thread
 
mh_shifat profile image
5hfT • • Edited

did you change the task.json file try this as i have said that i make some edits.

Collapse
 
mahdihasan profile image
Mahdi Hasan • • Edited

this modification in task.json is working with git bash

"args": [
          "cp",
          "'${file}'",
          "'${workspaceFolder}\\${fileBasename}'",
          "&&",
          "fileName=\"${fileBasename}\"",
          "&&",
          "objectFile=\"${fileName%.*}.out\"",          
          "&&",
          "g++",
          "'${fileBasename}'",
          "-o",
          "${objectFile}",
          "&&",
          "./${objectFile}",
          "<",
          "input.txt",
          ">",
          "output.txt",
          "&&",
          "rm",
          "${objectFile}",
          "&&",
          "rm",
          "${fileBasename}",
        ]
Enter fullscreen mode Exit fullscreen mode
Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
mh_shifat profile image
5hfT •

What do u mean setup vim??

Collapse
 
soham04 profile image
soham04 •

Your .json file link is not working, I got my work stoped in between due to that !!!

Collapse
 
mh_shifat profile image
5hfT •

Did you use this one ?

Collapse
 
soham04 profile image
soham04 •

these tasks.json will be only valid for this folder and its subfolder only ?

Thread Thread
 
mh_shifat profile image
5hfT •

not like that. Let me see you this

for different workspaces you have to make the tasks.json file once.

Collapse
 
erenyaeger profile image
Eren Yaeger •

Image description

Image description

This is what I'm getting...

Collapse
 
mh_shifat profile image
5hfT •

what is your default shell in this vscode space ?

Collapse
 
soham04 profile image
soham04 •

Will is save out code in github repo also ?

Collapse
 
virajasmane profile image
Virajas Mane •

It is showing hello.cpp : No such file or directory
and also fatal error no input files
can you please help??

Collapse
 
mh_shifat profile image
5hfT •

did you create input.txt in the same directory as the hello.cpp??

Collapse
 
amrita_kadam_fd9ffd175696 profile image
Amrita Kadam •

Yes thank you so much I just learned that I did not create a folder in the base folder and then the file.cpp.
This worked.

Collapse
 
saksham08jain profile image
saksham08jain •

Image description
I am getting this error,any help is greatly appreciated

Collapse
 
evils_paradise profile image
Rooghz •
[
        "cp",
        "\"${file}\"",
        "${workspaceFolder}\\jspwTest.cpp",
        "&&",
        "g++",
        "${workspaceFolder}\\jspwTest.cpp",
        "-o",
        "${workspaceFolder}\\jspwTest",
        "&&",
        "${workspaceFolder}\\jspwTest",
        "<",
        "input.txt",
        ">",
        "output.txt",
        "&&",
        "rm",
        "${workspaceFolder}\\jspwTest.exe",
        "&&",
        "rm",
        "${workspaceFolder}\\jspwTest.cpp"
      ]
Enter fullscreen mode Exit fullscreen mode

Try this it will work..You just have to mention where this 'jspwTest.exe/cpp' file will be present.

Collapse
 
erenyaeger profile image
Eren Yaeger •

Please someone help me out as this is not working in my vscode