CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Posts
    230

    how to open console window for debug prints

    hello all
    i have win32 gui application but when i debug it i need to do debug prints
    i was thinking about opening console window and print the debug strings
    but how can I open such console ?

  2. #2
    Join Date
    Apr 2008
    Posts
    133

    Re: how to open console window for debug prints

    You can use OutputDebugString to print debug statements to your VC++ IDE output window. If you still want to create a console window you can use CreateConsoleScreenBuffer.

  3. #3
    Join Date
    Nov 2003
    Posts
    1,902

    Re: how to open console window for debug prints

    >> If you still want to create a console window you can use CreateConsoleScreenBuffer
    This will not create a console window in GUI app. You can use AllocConsole() to create a console window - but your stdout and stdin descriptors will not be "hooked up" to it - so printf and cout will not work. You can use ReadConsole() and WriteConsole() - or you can "hook up" the CRT to the console to make normal CRT I/O work as expected.

    This is an older article on hooking up the CRT to a console, however, it's for the old CRT, not the 8.0 CRT that ships with VS 2005 and up. Although it may still work for the 8.0 CRT.
    http://www.halcyon.com/~ast/dload/guicon.htm

    gg

  4. #4
    Join Date
    Apr 2007
    Location
    India
    Posts
    21

    Resolved Re: how to open console window for debug prints

    You don't necessarily need a console window to print your debugging information. As already pointed out by another user, you can use OutputDebugString() to print information.

    You can use an application like DebugView to view the information printed out (if not the IDE), since it has several advantages over the IDE in what it does.
    Nobody can give you wiser advice than yourself. - Cicero

    Rajesh Subramanian.
    Codeproject.com: Visual C++ MVP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured