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.
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
00:04 Setting up VS code for DSA and CP 01:07 Setting up VS code for C++ 02:11 Setting up VS code for DSA and CP 03:22 Build a strong portfolio with projects and DS algo for placements. 04:24 Setup VS code for DSA and CP 05:31 Setting up VS code for DSA and CP is easy. 06:40 Set up VS code for DSA and CP 07:53 Setting up VS code for DSA and CP
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.
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.
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.
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.
*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.
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?
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?
finally done hogaya 1st class hii adventure sei bara tha 😅 guys if you facing problem then simply say chech discription and read cearfully then you do thar
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?
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.
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?
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
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.
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
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.
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
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.
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.
ld: file too small (length=1) file '/Users/ujjwalagrawal/Desktop/cpp/input.txt' for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation). having this error in my mac setting the above setting can you explain, i tried evrything ...chatgpt also but culdnt understand...
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
i followed the same procedure after the ctrl+shift+built therer is two JspwTest.cpp and JspwTest.exe and hellowolrd.exe file is created but the output is not showing . my code is written in the helloworld.cpp please help me on it and i choose cmd as command prompt but i am unable to fix it please help on it
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 ?
hi need help figuring out that i followed each and every step very carefully but still i get errors like the code ended with error and so on and i really cannot figure out anymore how to resolve the issue also there appeared to be no errors in the problems section this is the error that i get : 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. would appreciate any guidance
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
i can tell you are running in powershell terminal because it is written in your path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (see you are running in powershell.exe) if you were ran this code in command prompt it had shown cmd.exe and striver bhaiya already said you have to run in command prompt terminal for working and not in powershell terminal
@@abhinavpandey840pls tell what to do 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.
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
Why am I getting error after making changes in .json file, I am getting correct output but when I press Ctrl Shift B I get some error in compile and run.
FOR MACBOOK, it'a not working: Exception in thread "main" java.util.NoSuchElementException at java.base/java.util.Scanner.throwFor(Scanner.java:945) at java.base/java.util.Scanner.next(Scanner.java:1602) at java.base..... The terminal process "/bin/zsh '-l', '-c', 'javac /Users/xxxxxxx/L4_Problems.java && java L4_Problems < input.txt > output.txt'" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.
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?
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.
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
@@rathore3991 still waiting for his reply
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 ?
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 😊
I got excited reading your story. I'm just starting the course. Do you have any suggestions for me?
where are you placed now brother?
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!
[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
Really excited for this DSA series
#Day1
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
I am so much grateful to you for this video. I want it for the last few days.
Many many many thanks.🥰🥰🥰🙏
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
Thank You is not enough for you , You are the Real meaning of Striver!
Thanks Striver for sharing this ! It was of great help .
Thanks a lot, Raj for This Amazing Lecture... 🙂
00:04 Setting up VS code for DSA and CP
01:07 Setting up VS code for C++
02:11 Setting up VS code for DSA and CP
03:22 Build a strong portfolio with projects and DS algo for placements.
04:24 Setup VS code for DSA and CP
05:31 Setting up VS code for DSA and CP is easy.
06:40 Set up VS code for DSA and CP
07:53 Setting up VS code for DSA and CP
I was setting up VSCode just yesterday and faced difficulty omg and this vid comes out today ❤
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 ?
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!!
c++ setup not working for windows, getting "The syntax of the command is incorrect."
Review: Too Good to be free. This Man is Educating India for free.
Most awaited video. Thank you Bhaiya !!
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.
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
after almost wasting 50 hours on dsa in youtube I got you sir your explanation was just wowwww
this is what i was searching for.....thanku bayya
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
am i going to get the error message from the code like runtime aur compile time error message
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
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.
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
Thanks!!! Working like a Charm
*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.
Very nice explanation,God Bless You
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
Thanks for sharing your knowledge buddy. 😊
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?
Thanks for such informative videos
you are awesome.....loved your videos
Bhai thank u very much for this video 😊😊
thanks a lot striver, really helpful for me
when i press Ctrl + shift + B nothing happens ? what could be the reason?
This works for Ubuntu too 🥳
what did u chose for ubuntu mac or windows config?
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
Please make the strings playlist as soon as possible.
my mac does not have bits/stdc++.h how to add that??
finally done hogaya 1st class hii adventure sei bara tha 😅
guys if you facing problem then simply say chech discription and read cearfully then you do thar
bhaiya plz upload next series , eagerly waiting for linked list , greedy etc
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?
Bhaisaab this video was so important 🥹🥹🥹🥹
the windows one is not working
same yaar nah ho rha hai
@@ar3568row
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.
terminal open up even aftr cmd + shift + b
what can be done for this?
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.
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?
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
i am starting today , let me see how much does it take to reach codeforces 2000 rating
How's it going?
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
}
}
}
]
}
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.
I am getting this error :
* Executing task: copy "C:\Users\vinay\Documents\C++
ew.cpp" C:\Users\vinay\Documents\C++\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.txt > output.txt && del jspwTest.exe && del jspwTest.cpp
ParserError:
Line |
1 | … ++\jspwTest.cpp && g++ jspwTest.cpp -o jspwTest && jspwTest < input.t …
| ~
| The '
same
same bro
@@shydcuk
in windows it will not work if your default terminal is powershell make it cmd then it will work.
@@karanshah3818but it is still not working it is showing building for 10 min
Did you do any changes in the code
@@Bimplo-l6f i also faced this problem then i restarted vs code and it was working properly.
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
Where's that a2z course? There's no link in the description for that? 2:01
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.
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
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?
okay my output prints hey but my input 13 is not showing in output whats the reason?
do we need to everytime press ctrl+shift+b or can you do that with just run button
5:22 where is this code
Hi, Can anyone paste the task.json (C++) code for Windows, the one on the website doesn't work for me.
try this one it is working:
{
"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
}
}
}
]
}
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.
ld: file too small (length=1) file '/Users/ujjwalagrawal/Desktop/cpp/input.txt' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation). having this error in my mac setting the above setting can you explain, i tried evrything ...chatgpt also but culdnt understand...
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?
If you aren't findind that .json code in description, click on one of the links in description, there you will find it.
Not working for my windows giving
error : The token '&&' is not a valid statement separator in this version
Same
After pressing run it gives "demo.exe file does not exit". What changes should I make in my launch.json file to get the output???
Sir I can't show output. Ctrl+shift+b is not working.
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
i followed the same procedure after the ctrl+shift+built therer is two JspwTest.cpp and JspwTest.exe and hellowolrd.exe file is created but the output is not showing . my code is written in the helloworld.cpp please help me on it and i choose cmd as command prompt but i am unable to fix it please help on it
i have the same problem bro pls help me if you have already done
Tried doing for java but the output is shown on terminal but not output.txt I used tasks.json code provided in link for windows
how to stop exection when i stuck into a infinite loop??
remove that loop
ctr c
Thanks brother :)
Glad that it worked with a little help from gpt too.
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 ?
We can also install the competitve programming helper extension
on my Mac, when i click on terminal, then configure task, after that i can't the option of 'Create tasks.json file from template', what to do now?
Showing : The syntax of the command is incorrect. what should i do?
Great work
hi need help figuring out that i followed each and every step very carefully but still i get errors like the code ended with error and so on and i really cannot figure out anymore how to resolve the issue also there appeared to be no errors in the problems section this is the error that i get : 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.
would appreciate any guidance
I'm also having similar 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
i can tell you are running in powershell terminal because it is written in your path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (see you are running in powershell.exe) if you were ran this code in command prompt it had shown cmd.exe and striver bhaiya already said you have to run in command prompt terminal for working and not in powershell terminal
@@abhinavpandey840pls tell what to do
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.
oh my god i wanted this so much
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
Why am I getting error after making changes in .json file, I am getting correct output but when I press Ctrl Shift B I get some error in compile and run.
try this out
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile and run",
"type": "shell",
"command": "cmd",
"args": [
"/C",
"copy \"${file}\" \"${workspaceFolder}\\jspwTest.cpp\" && g++ \"${workspaceFolder}\\jspwTest.cpp\" -o \"${workspaceFolder}\\jspwTest\" && \"${workspaceFolder}\\jspwTest.exe\" < input.txt > output.txt && del \"${workspaceFolder}\\jspwTest.exe\" && del \"${workspaceFolder}\\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
}
}
}
]
}
task.json code for javascript link was not provided in the description will you please provide it.
It's in the website link.
Striver please make a playlist for STRINGS also.
Heeeeeey Striver, thank you 💝
Is java certifition exam (OCJP) is important?? Please make one video on it
No
this setup is not working for me as a mac user idk why it just dont ask input and just print some random set of integers please someone help
FOR MACBOOK, it'a not working: Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.Scanner.throwFor(Scanner.java:945)
at java.base/java.util.Scanner.next(Scanner.java:1602)
at java.base.....
The terminal process "/bin/zsh '-l', '-c', 'javac /Users/xxxxxxx/L4_Problems.java && java L4_Problems < input.txt > output.txt'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
great tip bhaiya.