for windows users : it will not work if your default terminal is Powershell make it cmd then it will work. to change default terminal : press->clt+shift+p->write:default terminal->change it to cmd.
Brother mera ye option hi nhi aa rha h what should I do? ctrl shift p me ye wala option hi nhi aa rha EDIT : fix ho gaya for anyone facing same problem, go to terminal on top -> new terminal -> click on the down arraw button just besides the + button, there you can find select default profile then do what Karan has told above Thanks Karan for helping me, Was stuck on this for half an hour 😅😅
@@AbjSir bhai mene select default profile pe click karke command prompt click Kia, lekin bro woh write:default terminal-> change it to cmd. Type kahape karu coz terminal me error dikharahe, CPP code bhi ruk karahu toh -1 se exit code ka error aarahe
Great tip Striver bhaiya but those who don't want to do these much set-up they can just install one chrome extension "CPH for Competitive programmers" this extension will automatically access test case and run it for all test case in your VS code system.
Bhaiyya Thank you so much for your A2Z dsa sheet. I am a ECE 2023 graduate and i love coding I started my dsa journey 2 week ago but i am in stuck to do which kinds of problems do i need to do. There comes your your sheet. Even though i am doing dsa in python i have fundamentals in C++ so while you doing c++ i tried to do that code in python .So it is very beneficial for me to understand the language difference. Once again thank you so much. I have more way to go through your sheet . Please bless me 😊
[IF ANYONE WANTS TO KNOW WHAT'S HAPPENING] This video is awesome! Just wanted to break down what's happening behind the scenes: The trick is to use tasks.json to redirect the default input stream to cin. Notice the command line options uses '' for output.txt. Those are actually compiler flags for g++! Super cool trick. 👍 For reference, see the value of tasks[1]["command"] in tasks.json at line 22 visible at the 5:21 mark in the video. I am just adding context to the magic! Thanks again for sharing.
The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command g++ -std=c++17 -o "demo" "C:\Users\Dell\OneDrive\C++\demo.cpp" && .\demo < input.txt > output.txt" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it. Those who are getting this type of problem , you are doing a mistake as you are running in windows powershell terminal and not in command prompt terminal and in new version of vs code you cannot change your default terminal as shown by other youtubers, for changing try following this steps: 1: Go to setting icon of vs code in lower left corner. 2: Go to setting option (where shortcut is showing ctrl+,). 3:search for default terminal. 4: here select the *default terminal profile for Windows* and change it to command prompt. *NOTE* : You need to change from workspace (it is just below the search bar where you had type default terminal) ,if you change from user side it will not change ,also it was the error from the beginning because you were changing default terminal from the user side and not the workspace side
bro even after doin this i am getting this again- * Executing task: g++ -std=c++17 -o "demo" "C:\Users\HP\Desktop\C++\demo.cpp" && .\demo < input.txt > output.txt 'g++' is not recognized as an internal or external command, operable program or batch file. * The terminal process "C:\WINDOWS\System32\cmd.exe /d /c g++ -std=c++17 -o "demo" "C:\Users\HP\Desktop\C++\demo.cpp" && .\demo < input.txt > output.txt" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.
Pls help its showing like this Executing task: copy "C:\Users\PRANAV\Desktop\demoo\.vscode\tasks.json" C:\Users\PRANAV\Desktop\demoo\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp 1 file(s) copied. jspwTest.cpp:1:1: error: expected unqualified-id before '{' token { ^ * The terminal process "C:\windows\System32\cmd.exe /d /c copy "C:\Users\PRANAV\Desktop\demoo\.vscode\tasks.json" C:\Users\PRANAV\Desktop\demoo\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.
So, yeah for me, it wasn't as simple as that but the AI ChatGPT, helped a lot. In my case, the code was compiling and running if both are done separately, Ctrl + Shift + B compiled the program and Ctrl+Shift+P > Run tasks > Run with input or output used to put the output in Output.txt. ChatGPT said the following steps, will work according to the case that C++ file is main.cpp ,input file is input.txt ,and output file is output.txt 1. Create the file build_and_run.bat and write the prompt in it @echo off g++ main.cpp -o main.exe main.exe < input.txt > output.txt 2. Next, change the json prompt to the following: { "version": "2.0.0", "tasks": [ { "label": "Compile and Run with Input and Output", "type": "shell", "command": "${workspaceFolder}\\build_and_run.bat", "group": { "kind": "build", "isDefault": true }, "detail": "Compiles and runs the program with input redirection and writes output to output.txt" } ] } The next time you use Ctrl + Shift + B, it will compile and run too. Hope it helps 👍
5:09 I don't have the "Create tasks.json file from template." option. Any fix? Edit: I found the solution, there is a direct file tasks.json in the .vscode file. Just show hidden files and you will find it.
Thank you Striver for making this course Language Independent , I am following the course in JavaScript only problem I have is that sometimes the codeStudio links you provide the platform doesn't have a Javascript Compiler but LeetCode has but anyways I code on Vscode now.
Bhaiya I'm in my 2nd year of college and its a tier 3 one , so most of us students depend on your DSA videos .. bhaiya we are really really respectful and grateful to you for your service ... And hope you will continue to do your best in everything 👍👍👍 bhaiya I wanted to ask that when will you be uploading the articles attached with the questions provided and Videos which are pending right now ?? Like is there a 1 week uploading thing or something ?? please reply to this comment coz many of us are waiting for the answer. If any viewers or Bhaiya yourself find this rude then I'm very very sorry ... coz I know that working + making videos is hectic work but just asking coz many of us dont know
Are the videos arranged in a sequential manner in A2Z playlist? I am learning c++ right now and will be doing dsa from your playlist. Also, when will that course be completed?
@@ultimatescience3842 In his current updated playlists he has covered till Binary Search hard, there are video solutions for advanced topics as well, from his old videos.
Note: It is checked verified method still if there is any minute trouble do ask me or ChatGPT like ai tools. Day 1: Introduction to DSA and Environment Setup Download the vs code required extensions then set-up your ide Day 1: Setting Up Your IDE Like a Pro Introduction When starting your coding journey, having an organized environment can significantly boost your productivity and ease the debugging process. Today, we’ll walk you through setting up your IDE using a JSON file to manage your coding files, input, and output separately. We’ll cover setups for Java, C++, and Python. Step 1: Why Use a JSON File? Using a JSON file to organize your projects helps in keeping your code, input, and output files separate, making it easier to manage and test your programs. It also allows for easy switching between different languages and projects. Step 2: Creating Your Project Structure (It can vary on every individual this is just an example) First, let’s create a directory structure: bash Copy code /my_project ├── code/ │ ├── main.cpp (or main.java, main.py) ├── input/ │ ├── input.txt ├── output/ │ ├── output.txt ├── config.json • code/: This folder contains your main source code file. • input/: Place your input files here. • output/: Your program’s output will be stored here. • config.json: This file will manage the paths and commands for running your program. Step 3: Writing the JSON Configuration Note : for windows users : it will not work if your default terminal is Powershell make it cmd then it will work. to change default terminal : press->clt+shift+p->write:default terminal->change it to cmd Create a config.json file in your project directory. C++ : { "version": "2.0.0", "tasks": [ { "label": "Compile and run C++", "type": "shell", "command": "g++", "args": [ "-std=c++17", "-O2", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "&&", "${fileDirname}\\${fileBasenameNoExtension}.exe", "", "output.txt", "&&", "del", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": ["$gcc"] } ] } For Java: { "version": "2.0.0", "tasks": [ { "label": "Compile and run Java", "type": "shell", "command": "javac", "args": [ "${file}", "&&", "java", "-cp", "${fileDirname}", "${fileBasenameNoExtension}", "", "output.txt" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": ["$javac"] } ] } Python: { "version": "2.0.0", "tasks": [ { "label": "Run Python", "type": "shell", "command": "python", "args": [ "${file}", "", "output.txt" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": ["$python"] } ] } These configurations will work for their respective languages, using input.txt for input and writing to output.txt for output. Conclusion With this setup, you’ll have a neatly organized workspace where your code, input, and output are separated, making testing and debugging your programs easier. This structure is a best practice for professionals.
Hi, i had setup my vs code for c++ seeing your video for it, i have a few doubts: now my normal run code button doesnt run in cases where i need to give an input, secondly everytime for an output i have to write ctrl+shift+b?
*OUTPUT NOT PRINTING ISSUE FIX IN WINDOWS* Step 1: Replace the following line "${workspaceFolder}\\jspwTest.cpp", with "\"${workspaceFolder}\\jspwTest.cpp\"", Step 2: 1: Go to setting icon of vs code in lower left corner. 2: Go to setting option (where shortcut is showing ctrl+,). 3:search for default terminal. 4: here select the default terminal profile for Windows and change it to command prompt.
Kindly solve this problem when i run this code at timeline - 5:40. Executing task: g++ -std=c++17 -o demo g++: fatal error: no input files compilation terminated. * The terminal process "C:\windows\System32\cmd.exe /d /c g++ -std=c++17 -o demo" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.
if facing errpr while running the java file, go to tasks.json and change label a liitle bit ...suppose Compile and Run. In my case, it worked after doing this, earlier the cpp task file was always getting run in java also.
For some reason there is no tasks.json file in the description and also, the json config provided in striver's website is not working however I tried this json and it is working fine. Thanks for helping out. If anyone is struggling to setup can reply me I have fixed hell lot of stuff for this setup.
Thanks Raj bhaiya for this configuration file, it is working completely fine with some minor modification using chatgpt. But it stuck when I accidentally execute infinite loop. Can you tell how to add time limit for execution similarly like we have on competitive platforms.
Yes there is Go to keyboard shortcuts and search the shortcut which is already there I think ctrl shift p it is so search that shortcut, like just search ctrl shift p and change it to whatever you want I have changed it to Alt + X
@striver could you please make a small video like this, regarding debugging using gdb/gcc in vscode specially for C++, cause its confusing where to put break point , how to debug in c++ as compared to java in Intellij , just a small example of for loop would help alot , I understand you are busy even if you drop some updated ressource regarding would really be grateful to you , if anyone from community knows any hands on tutorial please give a link in replies , thanks.
This is not working for c++ if i am reopening the c++ folder in vscode, it asks to select a build task to run , but even after selecting it does not work.The output does NOT change.
Not working in my laptop (macbook). I hv tried multiple times. Also tried to modify the task accordingly using ChatGPT but didn't work. Unable to find the reason
@@rajkumarchaudhary6783 yes brother, working fine basically i used the same template as provided, just insure that the path in which you have saved the folder or your cpp file, make sure the name of any folder should not contain spaces. For eg. if you have a folder named "abc def" make it "abc_def", that was the mistake i was doing, maybe helpful for you
i did the exactly same thing guys as told for mac but the bits extension file is showing erroe in my mac while running can someone tell me what I have done wrong?
I use windows 11. I have followed all the steps. But upon pressing ctrl+shift+b i get :" command syntex error" message in the terminal and bothing in output file. How can I fix it?
When I press ctrl+shift+B it showing me an error in jspwTest.cpp file. Error message: expected unqualified-id before numeric constant [Ln 1, Col 1].. expected a declaration C/C++(169) [Ln 1, Col 1]. Any solution?
@@babai2196 definitely! do give leetcode contests ! dont care about the ratings, just focus on getting intuition and ideas during the contest and increasing thinking and coding speed! P.S: I did this only and prepared for placements and got placed in a good company with good pay!
I am having a small issue with the TUF website. The problems that I mark as "done" are not saved. When I reload the page or access it from another device, the updates are not reflected. Is it with everyone ?
I am having issues in setting up vs code. The output is coming in the terminal of vs code instead of the txt file I created. Can anyone help me with it.
i use ubuntu and its not working. i used chat gpt changed task.json file but still shows output in terminal but not in output file, also does not take input from input file
Hello bro. Did your code executed I got error like: Executing task: javac /Users/lekhrajawasthi/Documents/Dsa/java/demo.java && java demo < input.txt > output.txt Error: Could not find or load main class demo Caused by: java.lang.NoClassDefFoundError: Demo (wrong name: demo). It is automatically converting Demo.class file to demo. What should I do.
getting this error pleaase help * Executing task: copy "C:\Users\anura\Desktop\C++\demo.cpp" C:\Users\anura\Desktop\C++\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp The syntax of the command is incorrect. * The terminal process "C:\WINDOWS\System32\cmd.exe /d /c copy "C:\Users\anura\Desktop\C++\demo.cpp" C:\Users\anura\Desktop\C++\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.
can someone help me I am getting this error "The syntax of the command is incorrect." in the terminal and I am not able to get any output in output.txt
in tasks.json , under "tasks" then under "args" " the first text is set to "python3" i have removed the 3 and just made it "python" . then , its working for me
My input txt and output txt are integrated after i asked gpt for modified task.json but every time i have to press ctrl shift B for output updation can it be automated
for windows users : it will not work if your default terminal is Powershell make it cmd then it will work.
to change default terminal : press->clt+shift+p->write:default terminal->change it to cmd.
Brother mera ye option hi nhi aa rha h what should I do?
ctrl shift p me ye wala option hi nhi aa rha
EDIT : fix ho gaya
for anyone facing same problem, go to terminal on top -> new terminal -> click on the down arraw button just besides the + button, there you can find select default profile then do what Karan has told above
Thanks Karan for helping me, Was stuck on this for half an hour 😅😅
@@AbjSir your welcome brother!
@@AbjSirbhai default terminal karke option nahi dikhara, power shell, git bash, command prompt ye sab dikharahe options me, kidar exactly click Karu?
@@avakashrajkonwar Command propt hi cmd hota h bro
@@AbjSir bhai mene select default profile pe click karke command prompt click Kia, lekin bro woh write:default terminal-> change it to cmd. Type kahape karu coz terminal me error dikharahe, CPP code bhi ruk karahu toh -1 se exit code ka error aarahe
how is he so underrated? He has undoubtedly best coding content one can access for free in youtub
This is really the best DSA course completely indepth ...insanely incredible
In which video i watch to start DSA course?
Are you finished DSA course?
Can you reply quickly?
After Solving 200+ Sheet question & Several Contest - This VS code installation is all we needed
Which ide you used before
@@ImranOnTheWeb Abb kuch nehi karta, wait karta hu
@@Akash-yr2ifkya karta ho bhai!
@@rathore3991 Abhi Job karta hu
Great tip Striver bhaiya but those who don't want to do these much set-up they can just install one chrome extension "CPH for Competitive programmers" this extension will automatically access test case and run it for all test case in your VS code system.
For windows users whose path contains spaces will face issues.
Just paste the below code , its the same code with a minute change in line "command"
Here is the corrected code
{
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"type": "shell",
"command": "g++",
"args": [
"-std=c++17",
"-o",
"${fileBasenameNoExtension}",
"${file}"
],
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "compile and run",
"type": "shell",
"command": "g++ -std=c++17 -o \"${fileBasenameNoExtension}\" \"${file}\" && .\\${fileBasenameNoExtension} < input.txt > output.txt",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
this helped me thanks!!
for java?
@@Avenger-l3g bro u can ask to AI regarding this
Ask either ChatGPT or Bard to convert this code for java
Thanks Buddy It Worked 😍
This did help me out! Thanks!
Bhaiyya Thank you so much for your A2Z dsa sheet. I am a ECE 2023 graduate and i love coding I started my dsa journey 2 week ago but i am in stuck to do which kinds of problems do i need to do. There comes your your sheet. Even though i am doing dsa in python i have fundamentals in C++ so while you doing c++ i tried to do that code in python .So it is very beneficial for me to understand the language difference. Once again thank you so much. I have more way to go through your sheet . Please bless me 😊
[IF ANYONE WANTS TO KNOW WHAT'S HAPPENING]
This video is awesome! Just wanted to break down what's happening behind the scenes:
The trick is to use tasks.json to redirect the default input stream to cin.
Notice the command line options uses '' for output.txt. Those are actually compiler flags for g++!
Super cool trick. 👍
For reference, see the value of tasks[1]["command"] in tasks.json at line 22 visible at the 5:21 mark in the video.
I am just adding context to the magic!
Thanks again for sharing.
I followed the steps as mentioned in the video but still i did not get the output
Best series on youtube for DSA
Thanks a lot Striver for the LL videos in the A2Z DSA Series... really enjoying the videos. You're the GOAT
I cannot see them. is LL playlist for members only ?
I belong to Python Community.
Thankyou Stiver, know the life is sorted. I use to type multiple inputs by running code again and again.
@@DEEKSHITH-bw6bo now I shifted to web development. But if you re-watch the complete video you will definitely find the solution to your problem.
Are you a college Student or doing job?
@@ImranOnTheWeb I am the college student.
@@studynewthings1727 which year brother
Review: Too Good to be free. This Man is Educating India for free.
I was setting up VSCode just yesterday and faced difficulty omg and this vid comes out today ❤
The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command g++ -std=c++17 -o "demo" "C:\Users\Dell\OneDrive\C++\demo.cpp" && .\demo < input.txt > output.txt" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
Those who are getting this type of problem , you are doing a mistake as you are running in windows powershell terminal and not in command prompt terminal and in new version of vs code you cannot change your default terminal as shown by other youtubers, for changing try following this steps:
1: Go to setting icon of vs code in lower left corner.
2: Go to setting option (where shortcut is showing ctrl+,).
3:search for default terminal.
4: here select the *default terminal profile for Windows* and change it to command prompt.
*NOTE* : You need to change from workspace (it is just below the search bar where you had type default terminal) ,if you change from user side it will not change ,also it was the error from the beginning because you were changing default terminal from the user side and not the workspace side
bro even after doin this i am getting this again- * Executing task: g++ -std=c++17 -o "demo" "C:\Users\HP\Desktop\C++\demo.cpp" && .\demo < input.txt > output.txt
'g++' is not recognized as an internal or external command,
operable program or batch file.
* The terminal process "C:\WINDOWS\System32\cmd.exe /d /c g++ -std=c++17 -o "demo" "C:\Users\HP\Desktop\C++\demo.cpp" && .\demo < input.txt > output.txt" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
It's showing that
The syntax of the command is incorrect
@@akshaybhardwaj7096 i also face the same problem , can anyone gave me the right solution
Pls help its showing like this
Executing task: copy "C:\Users\PRANAV\Desktop\demoo\.vscode\tasks.json" C:\Users\PRANAV\Desktop\demoo\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp
1 file(s) copied.
jspwTest.cpp:1:1: error: expected unqualified-id before '{' token
{
^
* The terminal process "C:\windows\System32\cmd.exe /d /c copy "C:\Users\PRANAV\Desktop\demoo\.vscode\tasks.json" C:\Users\PRANAV\Desktop\demoo\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
Thanks bro , it Worked!!
I am so much grateful to you for this video. I want it for the last few days.
Many many many thanks.🥰🥰🥰🙏
So, yeah for me, it wasn't as simple as that but the AI ChatGPT, helped a lot.
In my case, the code was compiling and running if both are done separately, Ctrl + Shift + B compiled the program and Ctrl+Shift+P > Run tasks > Run with input or output used to put the output in Output.txt.
ChatGPT said the following steps, will work according to the case that C++ file is main.cpp ,input file is input.txt ,and output file is output.txt
1. Create the file build_and_run.bat and write the prompt in it
@echo off
g++ main.cpp -o main.exe
main.exe < input.txt > output.txt
2. Next, change the json prompt to the following:
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and Run with Input and Output",
"type": "shell",
"command": "${workspaceFolder}\\build_and_run.bat",
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Compiles and runs the program with input redirection and writes output to output.txt"
}
]
}
The next time you use Ctrl + Shift + B, it will compile and run too.
Hope it helps 👍
Thanks a lot, Raj for This Amazing Lecture... 🙂
Thanks Striver for sharing this ! It was of great help .
Replace the following line "${workspaceFolder}\\jspwTest.cpp", with "\"${workspaceFolder}\\jspwTest.cpp\"", if output is not generating
WORKS ! DAMN thanks so much
Thanks a lot. Working just like that.
Not working pls help
@@_Phanindrak_ see the pinned comment in this video, for windows user make the default terminal to cmd
@@gada.shreebh i did it but output is not comping pls help
5:09 I don't have the "Create tasks.json file from template." option. Any fix?
Edit: I found the solution, there is a direct file tasks.json in the .vscode file. Just show hidden files and you will find it.
Thank you Striver for making this course Language Independent , I am following the course in JavaScript only problem I have is that sometimes the codeStudio links you provide the platform doesn't have a Javascript Compiler but LeetCode has but anyways I code on Vscode now.
Getting it fixed soon
hey, i am also starting with js as well. Any guide or any other resource which will be better. Please share
@@mod_cyber1015 hey,any resources you got in js ?
after almost wasting 50 hours on dsa in youtube I got you sir your explanation was just wowwww
This works for Ubuntu too 🥳
Most awaited video. Thank you Bhaiya !!
Bhaiya I'm in my 2nd year of college and its a tier 3 one , so most of us students depend on your DSA videos ..
bhaiya we are really really respectful and grateful to you for your service ... And hope you will continue to do your best in everything 👍👍👍
bhaiya I wanted to ask that when will you be uploading the articles attached with the questions provided and Videos which are pending right now ?? Like is there a 1 week uploading thing or something ??
please reply to this comment coz many of us are waiting for the answer.
If any viewers or Bhaiya yourself find this rude then I'm very very sorry ... coz I know that working + making videos is hectic work but just asking coz many of us dont know
Isme c++ bhi padhya hai na ? Pls tell? Merko c++ 0 aya hai basic se karya hai na?
ham tier 1 wale ko v jaroorat pdti hai bhai
c++ setup not working for windows, getting "The syntax of the command is incorrect."
Thanks!!! Working like a Charm
Are the videos arranged in a sequential manner in A2Z playlist?
I am learning c++ right now and will be doing dsa from your playlist.
Also, when will that course be completed?
Yes, it's in sequence. You will find everything topic-wise.
@@iamritam
Bro can you please tell me how much he has covered till now?
And what percentage of the course is still left?
@@ultimatescience3842 In his current updated playlists he has covered till Binary Search hard, there are video solutions for advanced topics as well, from his old videos.
this is what i was searching for.....thanku bayya
you are awesome.....loved your videos
Note: It is checked verified method still if there is any minute trouble do ask me or ChatGPT like ai tools.
Day 1: Introduction to DSA and Environment Setup
Download the vs code required extensions then set-up your ide
Day 1: Setting Up Your IDE Like a Pro
Introduction
When starting your coding journey, having an organized environment can significantly boost your productivity and ease the debugging process. Today, we’ll walk you through setting up your IDE using a JSON file to manage your coding files, input, and output separately. We’ll cover setups for Java, C++, and Python.
Step 1: Why Use a JSON File?
Using a JSON file to organize your projects helps in keeping your code, input, and output files separate, making it easier to manage and test your programs. It also allows for easy switching between different languages and projects.
Step 2: Creating Your Project Structure (It can vary on every individual this is just an example)
First, let’s create a directory structure:
bash
Copy code
/my_project
├── code/
│ ├── main.cpp (or main.java, main.py)
├── input/
│ ├── input.txt
├── output/
│ ├── output.txt
├── config.json
• code/: This folder contains your main source code file.
• input/: Place your input files here.
• output/: Your program’s output will be stored here.
• config.json: This file will manage the paths and commands for running your program.
Step 3: Writing the JSON Configuration
Note : for windows users : it will not work if your default terminal is Powershell make it cmd then it will work. to change default terminal : press->clt+shift+p->write:default terminal->change it to cmd
Create a config.json file in your project directory.
C++ :
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and run C++",
"type": "shell",
"command": "g++",
"args": [
"-std=c++17",
"-O2",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"&&",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"",
"output.txt",
"&&",
"del",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
}
]
}
For Java:
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and run Java",
"type": "shell",
"command": "javac",
"args": [
"${file}",
"&&",
"java",
"-cp",
"${fileDirname}",
"${fileBasenameNoExtension}",
"",
"output.txt"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$javac"]
}
]
}
Python:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Python",
"type": "shell",
"command": "python",
"args": [
"${file}",
"",
"output.txt"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$python"]
}
]
}
These configurations will work for their respective languages, using input.txt for input and writing to output.txt for output.
Conclusion
With this setup, you’ll have a neatly organized workspace where your code, input, and output are separated, making testing and debugging your programs easier. This structure is a best practice for professionals.
Thanks
Bahi apka A to Z series playlist kab tak khatam ho jayega
Please playlist ko acche se sequence me thoda ready karna.
Please respond me.
Please continue A2Z series sir
Yes, next you will see LL playlist dropping entirely in first week of october.
@@takeUforward thankyou so much sir
@@takeUforward Thank you sm
@@takeUforward thank you so much tab Tak binary search khatam
@@takeUforwardLekin bhaiya next step 5 toh strings tha n!
Thanks for sharing your knowledge buddy. 😊
Glad that it worked with a little help from gpt too.
Very nice explanation,God Bless You
Hi, i had setup my vs code for c++ seeing your video for it, i have a few doubts: now my normal run code button doesnt run in cases where i need to give an input, secondly everytime for an output i have to write ctrl+shift+b?
*OUTPUT NOT PRINTING ISSUE FIX IN WINDOWS*
Step 1:
Replace the following line "${workspaceFolder}\\jspwTest.cpp", with "\"${workspaceFolder}\\jspwTest.cpp\"",
Step 2:
1: Go to setting icon of vs code in lower left corner.
2: Go to setting option (where shortcut is showing ctrl+,).
3:search for default terminal.
4: here select the default terminal profile for Windows and change it to command prompt.
bhala kare bagwaan tera
thanks alot bro
Thanks a lottttt brother!!!
mann thanks a lottt
Thanks man !! this took me 1 whole hr to figure it out.
bhaiya plz upload next series , eagerly waiting for linked list , greedy etc
05:20 Where is the configuration code ? Can anyone provide me that ?
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and run",
"type": "shell",
"command": "",
"args": [
"copy",
"\"${file}\"",
"${workspaceFolder}\\jspwTest.cpp",
"&&",
"g++",
"jspwTest.cpp",
"-o",
"jspwTest",
"&&",
"jspwTest",
"",
"output.txt",
"&&",
"del",
"jspwTest.exe",
"&&",
"del",
"jspwTest.cpp"
],
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true,
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
Take it
Please make the strings playlist as soon as possible.
Thanks for such informative videos
Please continue A2Z series bhaiya
Bhaisaab this video was so important 🥹🥹🥹🥹
the windows one is not working
same yaar nah ho rha hai
@@ar3568row
Started a new journey from 01 June 2024
Which year
How is your experience with this course
If you aren't findind that .json code in description, click on one of the links in description, there you will find it.
thanks a lot striver, really helpful for me
Kindly solve this problem when i run this code at timeline - 5:40. Executing task: g++ -std=c++17 -o demo
g++: fatal error: no input files
compilation terminated.
* The terminal process "C:\windows\System32\cmd.exe /d /c g++ -std=c++17 -o demo" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
same
Bhai thank u very much for this video 😊😊
Sir I completed the setup but when I run the code jspwtest.cpp file occurs and output does not come. How to resolve this?? Please someone suggest
did u get the solution
Did solve it
Striver please make a playlist for STRINGS also.
if facing errpr while running the java file, go to tasks.json and change label a liitle bit ...suppose Compile and Run. In my case, it worked after doing this, earlier the cpp task file was always getting run in java also.
great tip bhaiya.
Where's that a2z course? There's no link in the description for that? 2:01
Started a new journey from 2nd July!
Same here!
Sir we await your string and heaps lectures on the playlist
Thanks Striver 🙌
For C++ & JAVA
was facing some errors of syntax in tas.json file on windows. Pasting working json
This will dynamically take the file that is active and you are working and run that.
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and run",
"type": "shell",
"command": "cmd",
"args": [
"/C",
"g++ \"${file}\" -o \"${fileDirname}\\${fileBasenameNoExtension}\" && \"${fileDirname}\\${fileBasenameNoExtension}\" < \"${workspaceFolder}\\input.txt\" > \"${workspaceFolder}\\output.txt\""
],
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
For those who want the same configuration for JAVA
Make sure you have jdk installed and added in path
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and run Java",
"type": "shell",
"command": "cmd",
"args": [
"/C",
"javac \"${file}\" && java -cp \"${fileDirname}\" \"${fileBasenameNoExtension}\" < \"${workspaceFolder}\\input.txt\" > \"${workspaceFolder}\\output.txt\""
],
"presentation": {
"reveal": "always"
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "java",
"fileLocation": [
"absolute"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
Thanks a lot for helping ❤
Thanks a lot for helping
Thank you so much for this
For some reason there is no tasks.json file in the description and also, the json config provided in striver's website is not working however I tried this json and it is working fine. Thanks for helping out. If anyone is struggling to setup can reply me I have fixed hell lot of stuff for this setup.
@@sheikhtahamaroof8484 the configuration given by Striver is not working for me. What should I do?
i am starting today , let me see how much does it take to reach codeforces 2000 rating
How's it going?
5:22 where is this code
Thanks Raj bhaiya for this configuration file, it is working completely fine with some minor modification using chatgpt. But it stuck when I accidentally execute infinite loop. Can you tell how to add time limit for execution similarly like we have on competitive platforms.
bro please reply when you'll get the solution.
Is java certifition exam (OCJP) is important?? Please make one video on it
No
great video, is there any way to change the shortcut to run the code to something else?
Yes there is
Go to keyboard shortcuts and search the shortcut which is already there I think ctrl shift p it is so search that shortcut, like just search ctrl shift p and change it to whatever you want
I have changed it to Alt + X
@@AbjSir thanks, i got it now
@striver could you please make a small video like this, regarding debugging using gdb/gcc in vscode specially for C++, cause its confusing where to put break point , how to debug in c++ as compared to java in Intellij , just a small example of for loop would help alot , I understand you are busy even if you drop some updated ressource regarding would really be grateful to you , if anyone from community knows any hands on tutorial please give a link in replies , thanks.
Bro....pls continue A2Z DSA sheet
Bro why are obsessed with CP. There is a beautiful whole new world with development.
System Design coming next year :)
Striver please upload next playlist either strings or LL. we have wait for quite long now
This is not working for c++ if i am reopening the c++ folder in vscode, it asks to select a build task to run , but even after selecting it does not work.The output does NOT change.
do we need to everytime press ctrl+shift+b or can you do that with just run button
Make video on strings please as soon as possible.... and update the sheet for A to Z
Not working in my laptop (macbook). I hv tried multiple times. Also tried to modify the task accordingly using ChatGPT but didn't work. Unable to find the reason
did you get any solution yet ?
@@rajkumarchaudhary6783 yes brother, working fine
basically i used the same template as provided, just insure that the path in which you have saved the folder or your cpp file, make sure the name of any folder should not contain spaces. For eg. if you have a folder named "abc def" make it "abc_def", that was the mistake i was doing, maybe helpful for you
i did the exactly same thing guys as told for mac but the bits extension file is showing erroe in my mac while running can someone tell me what I have done wrong?
when i press Ctrl + shift + B nothing happens ? what could be the reason?
hi striver! when can we expect strings playlist.
Striver, I am really slow while dry running the code and building the intuition. how can I improve that? How to think about edge cases?
I wish I could start your dsa course... but I am learning from C and yours is c++
No problem just understand the intuition and concept, that's important
i suggest shift to c++ c has not much scope c++ has STL also
@@parikshitrathore1510
I use windows 11. I have followed all the steps. But upon pressing ctrl+shift+b i get :" command syntex error" message in the terminal and bothing in output file. How can I fix it?
Same
please if u solve that issue then tell me
Do I have to pay for the notes on your website?
Please make a video on Travelling Saleman Problem using DP and Branch-bound
We can also install the competitve programming helper extension
When I press ctrl+shift+B it showing me an error in jspwTest.cpp file. Error message: expected unqualified-id before numeric constant [Ln 1, Col 1].. expected a declaration C/C++(169) [Ln 1, Col 1]. Any solution?
Same here, did it get resolve?
Do u recommend cp for final year students? Or just stick to sheets
Stick to sheets
Stick to Sheets and prepare for placements. That's enough.
@@phoenix_1_3 thanks man !!!
Do u recommend contests by any chance am really bad at it
@@babai2196 definitely! do give leetcode contests ! dont care about the ratings, just focus on getting intuition and ideas during the contest and increasing thinking and coding speed!
P.S: I did this only and prepared for placements and got placed in a good company with good pay!
@@phoenix_1_3 that's great buddy can we connect? Somehow like on LinkedIn
Thanks brother :)
starting it today
Sir I can't show output. Ctrl+shift+b is not working.
oh my god i wanted this so much
I am having a small issue with the TUF website. The problems that I mark as "done" are not saved. When I reload the page or access it from another device, the updates are not reflected. Is it with everyone ?
Great work
uninstalled my vs code the very first time I failed, re-installing it again. will update
didn't work yet. even changed the terminal but nope gives an error.
@@yashsaxena7787 did you find the solution? I am facing the same issue.
@@yashsaxena7787same for me 🥲
equivalent code for JAVA
{
"version": "2.0.0",
"tasks": [
{
"label": "compile and run",
"type": "shell",
"command": "javac ${file} && java ${fileBasenameNoExtension} < input.txt > output.txt",
"windows": {
"command": "cmd",
"args": [
"/C",
"javac ${file} && java ${fileBasenameNoExtension} < input.txt > output.txt"
]
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
I am having issues in setting up vs code. The output is coming in the terminal of vs code instead of the txt file I created. Can anyone help me with it.
i use ubuntu and its not working. i used chat gpt changed task.json file but still shows output in terminal but not in output file, also does not take input from input file
mac java not exwcuted directly but helped ...also chtagpt helped too.
Hello bro. Did your code executed
I got error like:
Executing task: javac /Users/lekhrajawasthi/Documents/Dsa/java/demo.java && java demo < input.txt > output.txt
Error: Could not find or load main class demo
Caused by: java.lang.NoClassDefFoundError: Demo (wrong name: demo).
It is automatically converting Demo.class file to demo. What should I do.
getting this error pleaase help
* Executing task: copy "C:\Users\anura\Desktop\C++\demo.cpp" C:\Users\anura\Desktop\C++\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp
The syntax of the command is incorrect.
* The terminal process "C:\WINDOWS\System32\cmd.exe /d /c copy "C:\Users\anura\Desktop\C++\demo.cpp" C:\Users\anura\Desktop\C++\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
same
Try this tasks.json(C++):
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and run",
"type": "shell",
"command": "",
"args": [
"copy",
"\"${file}\"",
"\"${workspaceFolder}\\jspwTest.cpp\"",
"&&",
"g++",
"jspwTest.cpp",
"-o",
"jspwTest",
"&&",
"jspwTest",
"",
"output.txt",
"&&",
"del",
"jspwTest.exe",
"&&",
"del",
"jspwTest.cpp"
],
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true,
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
Hello everyone
I am in a tier 3 college and i am starting this course today 17-01-2024 and my target is to complete it within 6 months .
Heeeeeey Striver, thank you 💝
Thanks bhaiya 😊
can someone help me I am getting this error "The syntax of the command is incorrect." in the terminal and I am not able to get any output in output.txt
in tasks.json , under "tasks" then under "args" " the first text is set to "python3" i have removed the 3 and just made it "python" . then , its working for me
bro actually how much time it will take to complete this course
Sir please make a video on rabin-karp and KMP algorithm of string pattern matching!!
My input txt and output txt are integrated after i asked gpt for modified task.json but every time i have to press ctrl shift B for output updation can it be automated