Click here to Skip to main content
15,920,602 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to open a database without MFC ? Pin
John M. Drescher25-May-03 3:42
John M. Drescher25-May-03 3:42 
QuestionIf 1 = true, 0 =false, why return 0 = successful? Pin
Link260024-May-03 21:01
Link260024-May-03 21:01 
AnswerRe: If 1 = true, 0 =false, why return 0 = successful? Pin
Ryan Binns24-May-03 21:27
Ryan Binns24-May-03 21:27 
AnswerRe: If 1 = true, 0 =false, why return 0 = successful? Pin
Michael Dunn25-May-03 2:53
sitebuilderMichael Dunn25-May-03 2:53 
GeneralRe: If 1 = true, 0 =false, why return 0 = successful? Pin
Link260025-May-03 3:01
Link260025-May-03 3:01 
GeneralRe: If 1 = true, 0 =false, why return 0 = successful? Pin
ZoogieZork25-May-03 10:00
ZoogieZork25-May-03 10:00 
GeneralRe: If 1 = true, 0 =false, why return 0 = successful? Pin
Link260025-May-03 11:30
Link260025-May-03 11:30 
GeneralRe: If 1 = true, 0 =false, why return 0 = successful? Pin
ZoogieZork25-May-03 14:32
ZoogieZork25-May-03 14:32 
VW_Red_Jetta wrote:
Some questions about EXIT_SUCCESS: is it always capitalized?

Yes, all identifiers in C and C++ are case-sensitive.

VW_Red_Jetta wrote:
And is it deifined in stdlib.h?

Yes, you can check for yourself... there will probably be a line like:
<br />
#define EXIT_SUCCESS 0<br />


VW_Red_Jetta wrote:
Could you tell me what does
EXIT_FAILURE do? How does it return on error?


The return value from main() in C/C++ is passed back to the parent process or the operating system. It's a good idea to use EXIT_SUCCESS and EXIT_FAILURE, particularly for command-line apps. In Unix (dunno about Win32), the return code can be useful when your program is being run as part of a script (I won't get into the crazy world of Unix shell scripting here).

Of course, in many cases, nobody is really listening to the return value. However, it's good to get into the habit of properly returning exit codes as defined by the language or API.

VW_Red_Jetta wrote:
Is there any alternative
to this method?


When returning from main(), EXIT_SUCCESS and EXIT_FAILURE are generally the way to go. Since you're using C++, keep in mind that within your app, returning a bool or int is not the only way to signal an error has occurred. Exceptions are a powerful and versatile system for dealing with error conditions, but can be overkill for dealing with simple errors.

- Mike
QuestionWhere do you put the braces? Pin
Link260024-May-03 16:55
Link260024-May-03 16:55 
AnswerRe: Where do you put the braces? Pin
Wes Aday24-May-03 17:35
professionalWes Aday24-May-03 17:35 
AnswerRe: Where do you put the braces? Pin
Beer24-May-03 17:47
Beer24-May-03 17:47 
AnswerRe: Where do you put the braces? Pin
Robert Little24-May-03 17:57
Robert Little24-May-03 17:57 
AnswerRe: Where do you put the braces? Pin
Paul M Watt24-May-03 19:02
mentorPaul M Watt24-May-03 19:02 
GeneralRe: Where do you put the braces? Pin
Link260024-May-03 19:04
Link260024-May-03 19:04 
GeneralRe: Where do you put the braces? Pin
Paul M Watt24-May-03 21:00
mentorPaul M Watt24-May-03 21:00 
GeneralRe: Where do you put the braces? Pin
Shafiee24-May-03 21:48
Shafiee24-May-03 21:48 
GeneralRe: Where do you put the braces? Pin
includeh1025-May-03 10:43
includeh1025-May-03 10:43 
AnswerRe: Where do you put the braces? Pin
Trollslayer25-May-03 0:02
mentorTrollslayer25-May-03 0:02 
AnswerRe: Where do you put the braces? Pin
markkuk25-May-03 1:06
markkuk25-May-03 1:06 
GeneralRe: Where do you put the braces? Pin
Michael P Butler25-May-03 9:06
Michael P Butler25-May-03 9:06 
AnswerRe: Where do you put the braces? Pin
Anonymous25-May-03 2:16
Anonymous25-May-03 2:16 
AnswerRe: Where do you put the braces? Pin
Michael Dunn25-May-03 2:56
sitebuilderMichael Dunn25-May-03 2:56 
AnswerRe: Where do you put the braces? Pin
John M. Drescher25-May-03 3:49
John M. Drescher25-May-03 3:49 
AnswerRe: Where do you put the braces? Pin
ZoogieZork25-May-03 10:12
ZoogieZork25-May-03 10:12 
AnswerRe: Where do you put the braces? Pin
John R. Shaw26-May-03 11:33
John R. Shaw26-May-03 11:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.