C++

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.
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

int main()
The Robomaniac
Project Head / Lead Programmer
Centaur Force
Phreak
Posts: 25
Joined: Mon May 10, 2004 2:01 pm

Post by Phreak »

Code: Select all

#include <stdin.h>
main()
{
    printf("Hello World\n");
}
I don't think stdin.h is a valid header file. What you want is stdioh, which has printf defined in it.

Phreak
If you don't succeed, redefine success!
Unarekin
Posts: 60
Joined: Thu Apr 22, 2004 11:02 pm

Post by Unarekin »

Robomaniac wrote:int main()
No, void main(). He isn't returning a value. If he were to put int main(), he would need to have, say, 'return 0;' at the end.
c_olin3404
Posts: 67
Joined: Fri Jan 23, 2004 5:04 am

Post by c_olin3404 »

Just a warning.... If you are going to learn c++, give it your all! Don't skip any chapters! And don't expect results too fast.

I did all of these things, and I was discouraged a bit... but now... 2 years later, I have learned so much, and the possibilities of C++ are endless. It is very rewarding and very fun.

Good luck man!

ps, a good site with some nice forums for c/c++ is www.cprogramming.com
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

c_olin3404 wrote:Just a warning.... If you are going to learn c++, give it your all! Don't skip any chapters! And don't expect results too fast.

I did all of these things, and I was discouraged a bit... but now... 2 years later, I have learned so much, and the possibilities of C++ are endless. It is very rewarding and very fun.

Good luck man!

ps, a good site with some nice forums for c/c++ is www.cprogramming.com
My advice would be to read it cover to cover first time, don't worry if it goes over your head a little because you can then jump to certain chapters once you know the way around the book. Don't expect to read it once and then just know C++, it's too complicated to do that. I still reference to a few C++ books my bro has when I'm in trouble.
warui
Posts: 232
Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:

Post by warui »

Unarekin wrote:
Robomaniac wrote:int main()
No, void main(). He isn't returning a value. If he were to put int main(), he would need to have, say, 'return 0;' at the end.
No, void main() is not a standard. Some compilers alows it, but official ANSI C++ standard forbids it.

And AFAIR you can define function w return type other then void and still don't use return in it's body. Some compilers will only give you warning about this. And others won't even warn you ;)
Tomasz Nowakowski
Openoko - www.openoko.pl
Coolkat
Posts: 25
Joined: Sun Mar 28, 2004 1:44 am
Location: U.S.A.

Post by Coolkat »

it's not #include <stdin.h> it's #include <stdio.h> and for C++ you don't need the .h at the end..

#include <iostream>

will work and is what is standard.

and what is so bad about sticking alittle return 0; at the end of a function?
IcePump Gaming
under construction
Phreak
Posts: 25
Joined: Mon May 10, 2004 2:01 pm

Post by Phreak »

Coolkat, all of those things have been covered. Also, I overlooked the main() return value, since I am used to a C compiler which doesn't require you to define the integer return value of the main function.

Phreak
If you don't succeed, redefine success!
warui
Posts: 232
Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:

Post by warui »

Coolkat wrote:it's not #include <stdin.h> it's #include <stdio.h> and for C++ you don't need the .h at the end..
Only for old c++ headers, for most (or even all, i don't remeber) c header we add "c" in the begining and drop ".h". So "stdio.h" changes into "cstdio".
Tomasz Nowakowski
Openoko - www.openoko.pl
Unarekin
Posts: 60
Joined: Thu Apr 22, 2004 11:02 pm

Post by Unarekin »

warui wrote:
Unarekin wrote:
Robomaniac wrote:int main()
No, void main(). He isn't returning a value. If he were to put int main(), he would need to have, say, 'return 0;' at the end.
No, void main() is not a standard. Some compilers alows it, but official ANSI C++ standard forbids it.

And AFAIR you can define function w return type other then void and still don't use return in it's body. Some compilers will only give you warning about this. And others won't even warn you ;)
It's bad form to define a return type and not return anything. ;)
Coolkat wrote:and what is so bad about sticking alittle return 0; at the end of a function?
Never said anything was bad about it, just that the return value was never specified. :)
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Dev C++ borks on void main if i remember, i just use int main and add a return 0;

or if i feel like it

bool main

return true;

:P

just whatever i feel

@duomaxwl -> Aim me if your having a little trouble, i can help you with some small stuff, however, i will not teach you everything you need, just if you need some help
The Robomaniac
Project Head / Lead Programmer
Centaur Force
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Also, it isn't bad form for the main function to have a return value of nothing, it's actually the standard. It's bad form to have void main() although most compilers allow it.
Unarekin
Posts: 60
Joined: Thu Apr 22, 2004 11:02 pm

Post by Unarekin »

Tyn wrote:Also, it isn't bad form for the main function to have a return value of nothing, it's actually the standard. It's bad form to have void main() although most compilers allow it.
I hope you aren't misunderstanding me: I meant to say it's bad form to declare a return type for a function, then not return anything. Then again, I rarely rarely rarely write a function without it returning something.
duomaxwl

Post by duomaxwl »

#include <stdio.h>
int main()
{
printf("Hello World\n");

return 0;
}

hehe... someone tell me whats wrong with this? please...
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Nothing should be, what errors do you get?
The Robomaniac
Project Head / Lead Programmer
Centaur Force
Post Reply