Output from Console Application

J

JezB

I'm compiling an old C program within Visual Studio to give me the
advantages of debugging within this environment. I'm building it as a
Console application using C++ as the language. It compiles and runs fine,
but if start debugging from within Visual Studio the standard output does
not seem to go anywhere. Standard output within my C program is via printf
commands. I dont want to start embedding Debug or Console statements since I
want the source to remain native C - I just want to compile and run it in
the visual studio environment.

How can I view the standard output within visual studio ? or how can I force
visual studio to run the program in a DOS window ?

The only way I can do what I want is to start the program in a dos window
then Attach to the process in visual studio, but this is not convenient as I
need to be able to step through the startup code.
 
S

ScottD

When you start debugging, a new console window is supposed to open.
The new console window is where the printf output goes.

Try a small hello.c type app first to sanity check the whole thing.
 
P

Peter van der Goes

JezB said:
I'm compiling an old C program within Visual Studio to give me the
advantages of debugging within this environment. I'm building it as a
Console application using C++ as the language. It compiles and runs fine,
but if start debugging from within Visual Studio the standard output does
not seem to go anywhere. Standard output within my C program is via printf
commands. I dont want to start embedding Debug or Console statements since I
want the source to remain native C - I just want to compile and run it in
the visual studio environment.

How can I view the standard output within visual studio ? or how can I force
visual studio to run the program in a DOS window ?

The only way I can do what I want is to start the program in a dos window
then Attach to the process in visual studio, but this is not convenient as I
need to be able to step through the startup code.
Further on what Scott said. The command prompt window is there and will
display the output. However, it will remain in the background unless your
program pauses for user input, at which point it will come to the
foreground. Of course you can see both concurrently if you don't maximize VS
and do a little arranging. To see the output as you step through code,
Alt-Tab to the command prompt window periodically.
Also note that in Debug mode, Visual Studio does not automatically pause
your program just prior to termination so you can review output as it does
when you run using "Start Without Debugging". I'm sure you already know how
to pause your program by prompting for input, so do that as the last
statement to hold output on the screen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top