Best way to output to the console window?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Best way to output to the console window?

Post 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".
Miwa
Posts: 28
Joined: Wed Feb 18, 2004 10:48 pm

Post 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.
Guest

Post 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!
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

(That was me)
warui
Posts: 232
Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:

Post 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.
Tomasz Nowakowski
Openoko - www.openoko.pl
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post 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...).
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post 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?
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post 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.)
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post 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)
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

FYI, I found one here;
http://www.cppreference.com/
Post Reply