![]() |
Logo Credits: Microsoft |
Most programs need user input and so you need to have a way to get user input while you are running your program. In VS Code, all the programs, by default, run and display the output in the Output section.
The thing with the output section is that it is a read-only section and you will not be able to input any value from that and if your application asks for user input and if it is running in the output section then your program will be stuck waiting for the user input.
The solution to this is that you will need to run your code in the integrated terminal instead of the output section.
The good news is that you can do that by using an extension called Code Runner. And by just clicking on one checkbox, you can make it possible.
Things you need
l Code Runner Extension
Code Runner Extension
If you have this extension then just go on to the next step and if not then you will need to install the code runner extension. Just search Code Runner in the extensions section search bar and install it.
After installing the extension, open Settings by going to Files > Preferences > Settings or you can use the shortcut keys Ctrl + ,
Now in the search bar there, just search for code runner and you will see all the settings related to the extension.
Then scroll down and search for the Run In Terminal checkbox.
Check it and that's it. Now try to run your program.
It should run your program in the terminal instead of the output section and you will be able to give any input to your program.
C Program Example
No comments:
Post a Comment