Page 1 of 1

Best way to output to the console window?

Posted: Mon Apr 26, 2004 4:58 am
by Domarius
Just want an easy way of making output, for testing purposes.
I was doing it the old way, by using cout, but I had to use #include <iostream>, #include <stdlib.h> and "using namespace std;" which I noticed added a huge amount of compile time - 10 seconds with it, as opposed to 1 second without (using the HelloWorld example).

I examined how Irrlicht.dll does it, it uses os::Printer::log("text stuff"); but I couldn't get it to work. I tried importing os.h like Irrlicht.dll does, and it says "os.h not found".

Posted: Mon Apr 26, 2004 5:54 am
by Miwa
You have a few ways to go about it. If cout was working, you could always just use printf instead.

One, if you want to use system headers, stuff will compile a whole lot faster if you use precompiled headers. It's what they are for, to speed up compiling.

Since you mention the Irrlicht DLL, I'm guessing you are on windows. You can also use OutputDebugString. You will need something to display output sent to OutputDebugString then, tho. I use dbmon.exe or just run in the debugger to see it.

If you are writing a console app (you have no winmain), then you can just use printf (ugh!). If you do have a winmain, you could always alloc yourself a console with AllocConsole, and printf to that too.

If you aren't using VC++, then you can reference the docs for the above functions at http://msdn.microsoft.com.

If you are using linux, you can likely just printf, and the output will go to a console somewhere.

Posted: Tue Apr 27, 2004 4:33 am
by Guest
Thanks Miwa - printf works fine, and without me adding any headers or anything :D. I guess it's a C++ keyword I didn't know about. (My experience is with Java)

And thanks for the tip about pre-compiled headers - makes sense!

Posted: Tue Apr 27, 2004 4:34 am
by Domarius
(That was me)

Posted: Tue Apr 27, 2004 11:32 am
by warui
No, printf is not a c++ keyword. It's normal function from stdio.h. You didn't have to include it because stdio.h must be already included somewhere in the irrlicht.

Posted: Wed Apr 28, 2004 7:17 am
by Domarius
Thanks for letting me know.

I'm embarrassed to say that I have no idea how to view the C++ SDK. (I'm using Dev-C++, and assume it comes with the download somewhere, but I don't know where it is...).

Posted: Wed Apr 28, 2004 9:15 pm
by Electron
what exactly do you mean by C++ SDK? I've never heard of anything called such. Are you talking about the standard library functions? or something else?

Posted: Thu Apr 29, 2004 7:18 am
by Domarius
Argh! I meant the API! Sorry.

Well I don't know what everyone calls the "big help file for C++", but in Java, its called the API.

http://java.sun.com/j2se/1.3/docs/api/

And for Irrlicht, it's the \doc\index.chm

Where is the equivelant thing for C++?
(That's bad - I'm asking a C++ question on the wrong forum.)

Posted: Thu Apr 29, 2004 7:44 pm
by Electron
well ,if there is a "big help file for C++" somewhere, I'd be interested in it. I've never heard of such a thing though. (Well I'm sure the ANSI C++ standard is documented somewhere, but I can't imagine an official standard being at all easy to understand)

Posted: Fri Apr 30, 2004 1:33 am
by Domarius
FYI, I found one here;
http://www.cppreference.com/