Closed sandip2224 closed 3 years ago
Tell me somehting :
Open terminal in the vs code
Go to the cpp file directory
cd Programs
Use manual command
g++ test.cpp -o test.out
./test.out
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 !
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:
I tried the above commands after disabling Windows defender (I don't have any additional antivirus installed) and got the same result.
P.S.: Ctrl+Shift+B is producing the same error.
@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 ?
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:
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
It's not working without the "freopen" inside main, and no, the Ctrl + Shift + b
isn't creating the .exe file
If it's not creating the exe file then just delete the exe file and try the shortcut (Ctrl + Shift + b) ?
I just did. It's stuck at ./test.out
without the 'freopen'. And works just fine with that.
using Ctrl + Shift + b
in vscode got stuck in ./test.out? I am not saying to use manual command from the terminal .
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.
give me the whole screenshot like this
Before running Ctrl+Shift+b
:
After running Ctrl+Shift+b
:
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 ?
O great finally it works. Seems like I had McAfee working all the while.
Yup that's why I told you to check your free antivirus :3
btw I'm closing this issue .
*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)