Archived

This topic is now archived and is closed to further replies.

UeberBobo

console window from win32

Recommended Posts

UeberBobo    122
can i somehow print things out in a console window from a win32 window. also how do i avoid using up all CPU when using a PeekMessage messageloop. i thought about setting a maximum FPS, would that work? i dont want to change my messageloop

Share this post


Link to post
Share on other sites
UeberBobo    122
can you give me an example as to how this works? i managed to get the window up with AllocConsole() but i dont know how to write or read aything from it.. how do i get it to print out some text?

Share this post


Link to post
Share on other sites
Kippesoep    892
Try


//Open console

if (AllocConsole ())
{
freopen ("CONIN$", "rb", stdin);
freopen ("CONOUT$", "wb", stdout);
freopen ("CONOUT$", "wb", stderr);
}

/*Just use it C-style*/
printf ("Hello world!");

//Or C++-style

cout << "Foo!" << endl;

//Release console

fclose (stdin);
fclose (stdout);
fclose (stderr);
FreeConsole ();


Share this post


Link to post
Share on other sites
maxd gaming    100
quote:
Original post by Kippesoep
Try


//Open console

if (AllocConsole ())
{
freopen ("CONIN$", "rb", stdin);
freopen ("CONOUT$", "wb", stdout);
freopen ("CONOUT$", "wb", stderr);
}

/*Just use it C-style*/
printf ("Hello world!");

//Or C++-style

cout << "Foo!" << endl;

//Release console

fclose (stdin);
fclose (stdout);
fclose (stderr);
FreeConsole ();





Do we need to include iostream/stdio?



It''s Maxd Gaming, put in an underscore and I will beat you with a rubber ducky!
{ Check out my Forum } { My First Space Art (Ever) }{ My Second Space Art (Ever) }{ My upcoming space mod for Battlefield: 1942. }