Visual Studio 2013 Displaying Output - visual-studio-2013

I'm new to VS. I came from Eclipse. Could anyone let me know how I can display the outputs as they were in Eclipse?
Anytime I "Run" (Build&Run) the code, the command line show up about a second and close up.
As I don't want to add any code like cin >> xxx to keep the command line window from closing, could anyone let me know how I can get the output within the Development window? Thanks!

There is no option in Visual Studio that says 'Build and Run', its either from 'Build' or 'Run' category. You build, and then run. When you run, it may build the solution, if necessary.
You can run solution either with deubugging (F5) or without debugging (Ctrl+F5). When you run with debugging, you may not see output. Run without debugging Ctrl+F5, and output window will wait for user input.
You may use (for testing purposes), getch, getchar or other function.

Related

Visual studio start line by line debugging in the middle of a program

I am working on a program and a lot of the buttons and menu items are dynamically created. Its especially hard to work on because I don't know where they are created and assigned to. It would help if I could start up the program via debugger, get to the menu, then switch to "line by line" style debugging like pressing F10, where the next line of code ran would break, and then press one of the buttons to get more info about it once the break happens. Is there any way I can do this in visual studio?
In Visual Studio, you have the Solution Explorer. There you see the Project files, they are under the top level Solution. If you right click on your main project, go to: Debug > Step Into New Instance.
If you work on a .NET application, you can use my Runtime Flow tool to see what code is executed when you select a menu item or press a button.
The closest way I could figure out how to do this is to go into Debug>Disable All Breakpoints and then when I get to where I need to be in the program go back and Enable All Breakpoints. Of course this only works if there is a large number of breakpoints in places in the program.

Is there any way to check currently executing code in visual studio?

I've been working on a C# project and I don't know the program flow. I want to know all the executing codes in a particular flow. I can press the pause button to check current executing code, but to check entire flow, I need to keep on pressing F11 or next line, which is cumbersome. BTW, I got it from here
Find out what line of code my app is currently running in Visual Studio's debug mode
I would like to know is there any way in visual studio to check currently executing code without pausing or placing break points?
I often use the VS debugging breakpoint or debug menu options like "Step Into/Out" or use the pausing button.
But if you don't want to use them, the Runtime Flow tool is a workaround I know which can help you see code that is executed:
Find out which line will be executed in Visual Studio debug mode
A feature request for VS IDE:
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/17332198-is-there-any-way-to-check-currently-executing-code
In VS2017, debug has a new feature called "Run execution to here", I know that it doesn't really meet your requirement, but it is a better workaround if you don't want to step Into debugging one step by one step. Move your mouse to the icon and click the button, now your code will run and stop on that line the next time it is hit in your code path.
If you want this ability at debug time then consider IntelliTrace
ReSharper has a Call Tracking feature that can display incoming and outgoing calls sequenced in an interactive, graphical tree view.
See if this helps.
The issue here is that there is code running but you don't know where and you want to see what is going on. A good example is the code is stuck in a loop somewhere but you don't know where.
To break-into the running code:
Option 1: Select the 'Debug' menu item, and then select the 'Break All' menu item.
Option 2: Press keys Ctrl+Alt+Break.
This will break into the code where it is executing and you will step into debugging just as if you hit a breakpoint.
Happy debugging!

Find out which line will be executed in Visual Studio debug mode

How can I find out which line will be executed after performing any action?
If I know what will be executed I can put break point there. But what if I am not sure where to set breakpoint or just I need to go to the executing line faster (without setting breakpoints).
"Break All" is not what I look for. It is pausing debugging, so I cannot perform any action (just after which I want Visual Studio sets breakpoint automatically)
In other words, for example I want to start debugging each line after clicking a button, without putting breakpoints. Is it possibile?
For a .NET application you can use my Runtime Flow tool (30-day trial) to see code that is executed after some action.
Set a breakpoint at the line you want to stop after. Then once the breakpoint is hit Step Into or press F11 in Visual Studio. This takes you to the very next line of code that executes, no matter where it is in the project.

Re-run a line of code during matlab debugging like Visual Studio?

Is there a possibility to re-run already executed line in matlab like Visual Studio. In Visual Studio, one can set the next line for execution in debug mode. Does matlab have this feature?
Not perfectly sure whether this is what you are looking for, but you can highlight some code with your mouse and then press F9 (note that this is the Windows shortcut, not sure whether linux or OSX are the same). The highlighted code will then be executed, this feature is called "evaluate selection".
I am not aware that you can interfere with the order of code execution in MATLAB in another way (except typing stuff in the command line while debugging).
Warning:
As suggested by Dan in the comment, note must be taken that this will alter the workspace and naturally this can interfere with the execution of your program in undesireable and at first unintuitive ways. You should keep this in the back of your head at all times while altering the workspace during program execution.

Visual Studio 2010 External Tools - How to automatically attach a debugger to the tool when it is started?

I am writing a DirectShow filter, and when I want to debug it I must:
Run GraphStudio (or GraphEdit) from Tools (I added it to external tools)
Click on Debug > Attach to process...
Search for "GraphStudio" in the process list
Double click on it...
Can this be automated in VisualStudio 2010? Like, I want to select an external tool from Tools menu, and get the debugger automatically attached to it...?
This isn't perfect but it saves you a couple of steps.
In Solution Explorer, right click on your project and select properties. Now select the debugging tab. Change the Command line from $(TargetPath) to GraphStudio.exe (or whatever your process name is). Change the Attach line from No to Yes. Click on OK.
Now your steps are
Run GraphStudio from Tools
Press F5 (or Start | Debug).
The debugger will attach to the process identified by the Command line entry. If there is more than one GraphStudio running it will attach to all of them.
If you don't need to run GraphStudio as an external tool then you can simplify things even further by changing the Attach line back to No and changing the Command line to hold the full pathname of the tool you want to run. If needed you can also set working directory and Command Arguments (switches etc.)
Now just start a debugging session by pressing F5. the debugger will run Graphstudio for you and will attach to that copy only.
You can use gflags or IFEO to do this. I mention it in this answer.

Resources