What does return zero mean by agreement?

This is probably a stupid question, but I always wonder what is the standard.

In most (not all) of the first C ++ examples, you can see that the main function returns 0. Does this mean that the operation went well or not?

  • 0 β†’ OK
  • 1 β†’ None.
  • Other β†’?

What is the standard way to do this?

By the way, is it better to return an integer or a logical number in this case?

Thanks guys!

+5
source share
7 answers

0 EXIT_SUCCESS . EXIT_FAILURE . . , std::exit(1) return 1; , .

EXIT_SUCCESS EXIT_FAILURE <cstdlib>.

: , , :

GNU make :

  • 0: , make .
  • 2: , make . , .
  • 1: , `-q ', make , - .

, , . :

  • , afaik
  • "" (windows, os x, unix), ++; , VMS .
+6

0 - , . int . main() C ++?

+2

C . , 0 . , .

++. ( ). - int, .

0

, (, , , POSIX, )

0, "" "". , , - other than 0, . , read(), , , , , . , 0, , . .

0
  • . /. , . , COM , ( S_OK, ). Windows (CreateFile ..) . , . , : !!!
  • . , int ( ). int bool EAX ( , x86), int bool.
0

. , , . ; , , , . , . 0, " ".

, , 0 - . , ... .

0

C/Unix.

script, script , . , 0 .

C , . .

, , , C/++ , , , ( ), .

, , /, 0 1 . , , enum, - -, , .

0
source

All Articles