Get all semester notes for Computer Engineering here.

Code runner in VS Code not working for taking input in C

Fixing Code Runner in VS Code not working for taking input and keeps running

Code runner in VS Code not working for taking input in C

If you use code runner in VS Code and you are having issues in running programs that take input from users there is one setting you need to change in your VS Code that will fix this problem.

Code runner in VS Code not working for taking input in C

Here I have written a simple program that takes an integer input from users and prints it. But when I heat run code in VS Code that code runner runs and keeps running never prompt me anything. Even If I close the output section the Code runner is running in the background.

Many people face this problem, there is a small thing to notice when we run the program it opens the output window. "OUTPUT" window, So how can we expect it to take input from users? So we need to set Code Runner to run where we can input data. There is an inbuilt terminal in VS Code and the terminal can also take input. So we need Code Runner to run inside the terminal.

Setting Up Code Runner to run in terminal

You need to open settings and search for Code Runner.

Code runner in VS Code not working for taking input in C

Locate Code-runner: Run In Terminal and click the check button and you are good to go.

If you want to do it the coder way then open the settings.json file, and paste the following code in it.

"code-runner.runInTerminal": true,{codeBox}


Make sure not to miss spell anything copy and paste it as it is. Here is my setting

Code runner in VS Code not working for taking input in C

Ignore other settings and just paste the line I gave you properly. Save it and reopen VS Code. And now let's see if it is working properly or not.

Code runner in VS Code not working for taking input in C

You see it's working now. We are allowed to make an input because the Code Runner is running inside the terminal.

Also read: Write a C Program to sort an array of strings in dictionary order

I am into computer science.

Post a Comment

Feel free to comment.