I can see my code being executed in the terminal window but the output screen does not pop up when I hit run . The output window on the console shows running and then done but the black screen with the result does not pop up like it used to before.I might have changed some settings in vscode but now I can't find the right one to change.
There can be many reasons. I'm afraid the changes you've applied caused this but no worries I suggest going over your project settings and VSCode's settings.
Check out these two links:
VS Code settings
C / CPP Config
P.S. I'm suggesting the second link based on your C tag.
Check your debug window too:
Menu -> Debug Console
or
Ctrl+Shift+Y.
Related
#include <stdio.h>
int main()
{
int a,b;
printf("Enter the value of a\n");
scanf("%d",&a);
printf("Enter the value of b\n");
scanf("%d",&b);
printf("The sum of a and b is %d", a + b);
return 0;
}
When i run this code in Microsoft Visual Code the code doesn't stop executing nor do i get the output. It starts running but it does not stop. I am also not getting any output. Other type of code is working perfectly fine.
Anyone can help me with this?
click here for image from vscode showing the running window
The code you have written is 100% correct.
Take care of the following things, check it out, if you have done them:
Install gcc in your system. gcc helps u compile c or c++ codes.
Install a C/C++ extension from the extensions section in the visual studio code.
At last, if the situation is still the same, try to re-install the visual studio code.
I hope, this might helps you. If you liked my suggestion, please press the upvoke button to motivate me to write such answers for you.
Thanks!
if this thing happens again first again try to execute the same code with some other IDE or run your code separately with CMD or PowerShell.
Code runner extension runs code in the output file which can not be interacted with. You have to change it so it runs in the terminal.
Go to the menu Code > Preferences > Settings.
In the User tab on the left panel, expand the Extensions section.
Find and select Run Code Configuration.
Find and check the box Run in Terminal.
I had exact same problem and it turns out I forgot to save the code:)
The main reason why code is not running is because it is running in "Output" Window, which I had shown in the linked Image.
If you want to run code properly then you have to run it in "Terminal" Window.
For running your code in "Terminal" window you have to follow these steps:
Step 1: Open Settings.
Step 2: Then type "Run in Terminal" in search box of the setting. Scroll below and find that setting.Install code runner if you haven't.
Step 3: Tick the box which is in 2nd line.
After that your code will run properly.
I have a big problem with CodeBlocks right now.
If I make somewhere a breakpoint, and start the debugger, it will show the code until the breakpoint.
The problem starts here:
If I want to go to the next line for example, it won't work. In the Info Box/Console messages, there is a message called:
"In ?? () () "
"Cannot find bounds of current function"
What could it be?
Furthurmore, I noticed one thing when I compare CodeBlocks on my desktop PC with that on my Virtual Machine (on a Notebook). Is that on the Desktop he goes by a path that includes Python 2.7, while on my Notebook this path is nowhere visible.
I hope somebody can help me out! Thanks for any help!
It is not the first time that I have encountered this problem, mainly your debugger must be hosted in a folder that contains incompatible characters, at least that is the reason I gave it, download MINGW or some debugger of the same style, what I did was create a path without special characters or spaces.
This is how I fixed it, I hope it work for you too.
How to use a debugger in DEV C++? I am finding problems resolving run-time errors in my C code written in DEV C++. How can the debugger help me resolve the run-time errors?
First, make sure you are using a project.
Then go to Project Options - Compiler - Linker and set Generate debugging information to "yes", and make sure you are not using any optimization options (they're not good for debug mode). Also check the Parameters tab, make sure you don't have any optimization options (like -O2 or -O3, but -O0 is ok because it means no optimization) or strip option (-s).
After that, do a full rebuild (Ctrl-F11), then set breakpoint(s) where you want the debugger to stop (otherwise it will just run the program). To set a breakpoint on a line, just click on the gutter (the gray band on the left), or press Ctrl-F5.
Now you are ready to launch the debugger, by pressing F8 or clicking the debug button. If everything goes well, the program will start, and then stop at the first breakpoint. Then you can step through the code, entering function calls, by pressing Shift-F7 or the "step into" button, or stepping over the function calls, by pressing F7 or the "next step" button. You can press Ctrl-F7 or the "continue" button to continue execution till the next breakpoint. At any time, you can add or remove breakpoints.
When the program stopped at a breakpoint and you are stepping through the code, you can display the values of various variables in your program by putting your mouse over them, or you can display variables and expressions by pressing F4 or the "add watch" button and typing the expression.
I got the same issue Although selecting the break points and select debug, debugging not working. I solved the problem as below:
Be sure that project is opened.
Display the project panel:
View>Project /Class Browser, Select Debug tab from the project panel
Set the base compiler:
Project > Project Options > Compiler > Linker
select the base compiler as “TDM-GCC 4.9.2 64 bit Debug”
Set the “Generate debugging information” as YES
Execute > Rebuild
To debug:
Execute > Toggle Breakpoint, then set the breakpoints.
Execute > Debug
Also check that at the menu bar base compiler is displayed as “TDM-GCC 4.9.2 64 bit Debug”
After selecting rebuild if directly breakpoints are set without selecting Toggle BreakPoints debugging is not started. Before selecting debug, selecting Toggle Breakpoint and then setting breakpoints solved the debug problem in my case.
I have stage server which I use it with Xmanager. In the stage sever,after whatever I choose using the mouse,a "^C" will appear automatically after $.For example ,I choose "system/" with mouse,and a "^C" soon appears in the command line.
It never happened before until yesterday I tried "Shift+Ctrl+V" which means "copy" after I choosing the command line which I wanted to copy, but it didn't work although I tried several times.And then the problem I described existed.
It's really confusing,and I don't whether "^C" has any bad effect.
How to resolve this problem?Anyone knows why it happened?
The reason causing this problem is that I opened youdao dictionary simultaneously with its function of catching words on the screen on. Just close it and the problem won't happen again. I don't know why maybe it has something to do with the software's compatibility.
In eclipse, how do I tell the console to submit the text? When I press enter, it just goes to a new line where I can continue typing and does not submit the text to continue processing.
To heck with eclipse.. I found a way of getting Visual Studio to compile C++ projects as C projects.. much better... after spending so many hours trying to get the IDE working with all its quirks... I don't think I'll be going back to that again (at least not for anything C anyway).
For anyone interested:
http://www.daniweb.com/software-development/cpp/threads/16256/compiling-c-in-visual-studio.net
Basically:
Go to project properties
Go to C/C++ node
Select "Advanced" subnode
Go to property "Compile As" and select option "Compile as C Code (/TC)"
Click OK and go back to solution explorer..
Change file extensions from .cpp to .c
That's it..