jspw / VS-Code-Config

VS Code Setting (Live input output) to make competitive programming easy and program analysis !
GNU General Public License v3.0
128 stars 45 forks source link

Ctrl + Shift + B produces unexpected errors. #4

Closed sandip2224 closed 3 years ago

sandip2224 commented 3 years ago

*The terminal process "C:\Program Files\Git\bin\bash.exe '-c', ' cp C:\Users\SD\Desktop\CP\Programs\test.cpp C:\Users\SD\Desktop\CP && g++ test.cpp -o test.out && ./test.out < input.txt > output.txt && rm out && rm test.cpp'" failed to launch (exit code: 1).

Terminal will be reused by tasks, press any key to close it.

P.S. I use Windows OS(64-bit)

1

jspw commented 3 years ago

Tell me somehting :

is this working fine in your machine ? Is there any anivirus running ? like avast or something which can prevent running programmes ? You can also delete the test.cpp file and create a new one and try again !

sandip2224 commented 3 years ago

Yeah I tried the manual build commands but it asks for user input via the terminal itself instead of reading from the input.txt file. Moreover output it showing up inside the terminal.

Here's the commands I used inside Programs folder:

  1. g++ test.cpp -o test.out
  2. ./test.out

I tried the above commands after disabling Windows defender (I don't have any additional antivirus installed) and got the same result.

1

P.S.: Ctrl+Shift+B is producing the same error.

jspw commented 3 years ago

@sandip2224 i think it's the test.exe file which is making the error ! Delete this and try ctrl+shift+b

Is ctrl+shift+b making the exe file ?

sandip2224 commented 3 years ago

Tried reinstalling MinGW and re-checked environment variable path.

So weird but now it WORKS just fine with Ctrl+Shift+b using test cases from input.txt and prints result to output.txt. Only had to add these lines inside my main() function.

freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);

Could you please explain how/why this works?

P.S.: I used the following manual build commands:

  1. g++ test.cpp -o test.out
  2. ./test.out
jspw commented 3 years ago

MinGW was working fine in your machine that's why i asked to use manual commands. Isn't it working without "freopen" in your main function ? And i have also asked a question that "was my script creating the exe file ? " @sandip2224

sandip2224 commented 3 years ago

It's not working without the "freopen" inside main, and no, the Ctrl + Shift + b isn't creating the .exe file

jspw commented 3 years ago

If it's not creating the exe file then just delete the exe file and try the shortcut (Ctrl + Shift + b) ?

sandip2224 commented 3 years ago

I just did. It's stuck at ./test.out without the 'freopen'. And works just fine with that.

jspw commented 3 years ago

using Ctrl + Shift + b in vscode got stuck in ./test.out? I am not saying to use manual command from the terminal .

sandip2224 commented 3 years ago

Okay give me a second. Here's what it's showing inside the bash terminal now. But I don't see any output in output.txt. 11

jspw commented 3 years ago

give me the whole screenshot like this

sandip2224 commented 3 years ago

Before running Ctrl+Shift+b:

1

After running Ctrl+Shift+b:

2

jspw commented 3 years ago

which task.json file you are using? The fisrt one when you got the launch faild error and now you are giving me the pictures are not using same script i guess! And 2nd question is : "where is the exe coming from ? p1

image

sandip2224 commented 3 years ago

O great finally it works. Seems like I had McAfee working all the while.

jspw commented 3 years ago

Yup that's why I told you to check your free antivirus :3
btw I'm closing this issue .