Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


c++ int main() / void main() ?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ups2000ups
I post too much
Reputation: 0

Joined: 31 Jul 2006
Posts: 2471

PostPosted: Sat Sep 22, 2007 7:25 am    Post subject: c++ int main() / void main() ? Reply with quote

well i reading a book (my 2 friends read books too)
and in all the books they always say use "int main()" but my programing friend say it is wrong i should use "void main()" oO

why does the book say i should use int always and he say void and whats the best ....

or dosent it effect my programs anyway ?

_________________
dont complain about my english...
1*1 = 2?
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sat Sep 22, 2007 7:34 am    Post subject: Reply with quote

Well it's good practise to use int main(), even if you don't want to return a value. void means no return value and int means return value. The reason is that, if you use int, and then return 0, or 1, it will know if there is an error or not, so it's just good practise.
_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Sep 22, 2007 7:34 am    Post subject: Reply with quote

It works either way. Theres more then just those as well.

int main() expects a return value. While void main() doesn't.

Then you can also have stuff like:
int _tmain(int argc, _TCHAR* argv[])

Which gives you access to things easily such as the current folder path via the argv array and various other things. (They are used for command line functions and such.)

Edit:: Bah, --Pillboi-- beat me to the post lol. And yea, like he/she said, using a return value for everything is good practice.
Back to top
View user's profile Send private message Visit poster's website
Robotex
Master Cheater
Reputation: 0

Joined: 05 Sep 2006
Posts: 378
Location: The pizza country!

PostPosted: Sat Sep 22, 2007 10:09 am    Post subject: Reply with quote

some compilers will give error if you use void
_________________

ASM/C++ Coder
Project Speranza lead developer
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Sat Sep 22, 2007 11:00 am    Post subject: Reply with quote

you should not use void main() because the shell needs to know whether you succeeded or failed
Back to top
View user's profile Send private message
zart
Master Cheater
Reputation: 0

Joined: 20 Aug 2007
Posts: 351
Location: russia

PostPosted: Sat Sep 22, 2007 11:10 am    Post subject: Reply with quote

appalsap wrote:
you should not use void main() because the shell needs to know whether you succeeded or failed


Exactly what appalsap said;

More reading on the matter;
http://www.eskimo.com/~scs/readings/voidmain.960823.html

_________________
0x7A 0x61 0x72 0x74

TEAM RESURRECTiON
Back to top
View user's profile Send private message
ups2000ups
I post too much
Reputation: 0

Joined: 31 Jul 2006
Posts: 2471

PostPosted: Sat Sep 22, 2007 12:12 pm    Post subject: Reply with quote

okay thanks =D
_________________
dont complain about my english...
1*1 = 2?
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sat Sep 22, 2007 1:11 pm    Post subject: Reply with quote

void main(void)
{
//Block
}


This is a sample in C
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Sep 22, 2007 1:38 pm    Post subject: Reply with quote

Kaspersky wrote:
void main(void)
{
//Block
}


This is a sample in C


edit: nvm

_________________
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sun Sep 23, 2007 7:54 pm    Post subject: Reply with quote

Kaspersky wrote:
int main(void)
{
//Block
return 0;
}


This is an improved sample in C
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Sep 23, 2007 7:57 pm    Post subject: Reply with quote

lol
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Mon Sep 24, 2007 5:12 am    Post subject: Reply with quote

Flyte wrote:
Kaspersky wrote:
int main(void)
{
//Block
return 0;
}


This is an improved sample in C


I'm still a begginer in C, shit!.
Back to top
View user's profile Send private message
ups2000ups
I post too much
Reputation: 0

Joined: 31 Jul 2006
Posts: 2471

PostPosted: Mon Sep 24, 2007 5:23 am    Post subject: Reply with quote

why do all write in C lol thats older then my gfs brother oO like +31 years ago ...

c++ is so much better

_________________
dont complain about my english...
1*1 = 2?
Back to top
View user's profile Send private message
Robotex
Master Cheater
Reputation: 0

Joined: 05 Sep 2006
Posts: 378
Location: The pizza country!

PostPosted: Mon Sep 24, 2007 5:27 am    Post subject: Reply with quote

ups2000ups wrote:
why do all write in C lol thats older then my gfs brother oO like +31 years ago ...

c++ is so much better

c/c++ entry points are same

_________________

ASM/C++ Coder
Project Speranza lead developer
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Mon Sep 24, 2007 5:31 am    Post subject: Reply with quote

ups2000ups wrote:
why do all write in C lol thats older then my gfs brother oO like +31 years ago ...

c++ is so much better


You MUST! learn C before anything else -_-" !

It's like learning math without knowing 2*2 or 1+1 -_-

@ Robotex

Wrong.

They have diffrent syntax, for example:

C is printf(" ")

C++ is cout << " " (not 100% sure)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites