472,358 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

iostream & Adding Console I/O to a Win32 GUI App

Hi all,
I'm trying to use the method described in the article

Adding Console I/O to a Win32 GUI App
http://dslweb.nwnexus.com/~ast/dload/guicon.htm

to output info to a separate console window.

I copy-pasted the code into my project and uncommented the last line

ios::sync_with_stdio();

to point cout, cin, etc to the console as well, but for some reason this
doesn't work. Using

fprintf(stdout, "some text")

works, but

cout << "some text" << endl

does nothing.
Could this have something to do with my configuration? (VS.NET, STLport
4.6 with own iostreams (no wrapper), DirectX9)?
Thanks!

T

Jul 22 '05 #1
1 3047

"Tony Boloney" <tb******@lycos.com> wrote in message
news:cm*********@snic.vub.ac.be...
Hi all,
I'm trying to use the method described in the article

Adding Console I/O to a Win32 GUI App
http://dslweb.nwnexus.com/~ast/dload/guicon.htm

to output info to a separate console window.

I copy-pasted the code into my project and uncommented the last line

ios::sync_with_stdio();

to point cout, cin, etc to the console as well, but for some reason this
doesn't work. Using

fprintf(stdout, "some text")

works, but

cout << "some text" << endl

does nothing.
Could this have something to do with my configuration? (VS.NET, STLport
4.6 with own iostreams (no wrapper), DirectX9)?


The author of that article seems to misunderstand what sync_with_stdio does.
Its purpose is to synchronize output to stdout with cout (for instance) so
that writes to these two stream appear in the right order. It certainly has
nothing to do with redirecting anything. In any case synchronization is on
by default and you would normally call sync_with_stdio to turn it off.

stdout and cout are guaranteed to write to the same place by the C++
standard, but the author of that article has written a lot of non-standard
code which has presumably broken that guarantee. He seems to be redirecting
stdout and then assuming that will simply redirect cout.

It could be that if you switch to another STL (for instance the one that
ships with the MS compiler) that this code will work, but I think the only
way to find out is to try it.

Alternatively you could do the proper thing which is to write you own custom
stream buffer classes which will do console I/O for you. Or find something
like that on the web, I'm sure it's been done many times before.

John
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eitan | last post by:
Hello, I am using Visual Studio.net 2003. I am trying to find how to create Win32 DLL & Win32 Static Library. When going through the wizard it does not show me the option for these two project...
19
by: ernst.stiegler | last post by:
Hello, I just want to read a whole line from a console input. What I don't understand is that I always have to press ENTER twice in order to see the line I've entered. Here's my code : ...
1
by: Bill Sun | last post by:
Hi, I just want to using a console application in the .net enviroment. Before the main(), I using the #include "iostream.h" but the .net tell me:...
7
by: Brian | last post by:
Hi, I have been trying to tune my vc7 compiled applications to perform at the same or (preferably) better speed of the same vc6 application. Both versions of my code are compiled with...
5
by: David | last post by:
Hello, I really need help. I use C++ VisualStudio.net version 2002. I tried to create a very simple console app. However, it won't compile, then I found out that I am missing two important...
7
by: Robert | last post by:
Hello, I'm using Pythonwin and py2.3 (py2.4). I did not come clear with this: I want to use win32-fuctions like win32ui.MessageBox, listctrl.InsertItem ..... to get unicode strings on the...
1
by: AlwaysPerplexed | last post by:
Hi, I'm somewhat stuck and could really appreciate some help. I'm writing a little program using the OpenCV libraries, I started this as a Win32 Console Application and everything worked fine. I...
0
by: jbenezech | last post by:
Hi all , I have a perl/java app running under Win32. The application consists of a perl service (Win32::Daemon) and of java classes. The perl service calls every xx hours java classes to perform...
11
by: gumboots | last post by:
Hi there guys, I've recently purchased "Sam's Teach Yourself C++ Fifth Edition" (About a week before the 6th edition came out) I'm trying to work through the book, but in trying to compile Hello...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.