Possible Duplicates:
main() functions return value?
What should main() return in C/C++?可能的重复:main()函数返回值?main()在C/ c++中应该返回什么?
What is the purpose of the returning of a value from main() in the languages C and C++?
从main()返回C和c++语言中的值的目的是什么?
How the return value helps us?
返回值如何帮助我们?
Can the return value be used to achieve anything important?
返回值可以用来实现任何重要的事情吗?
5 个解决方案
#1
11
It's the exit status. It's typically used to signal to the OS whether the process was successful or not in whatever it was doing.
它的退出状态。它通常用于向操作系统发出信号,表明该过程在其所做的任何事情中是否成功。
#2
4
It indicates the execution status of the program. Usually zero means it went fine.
它指示程序的执行状态。通常0表示一切正常。
#3
3
On most operating systems, the return value becomes the value returned from the process when it exits. By convention, a return value of zero signifies a normal exit, while non-zero values signify different abnormal termination conditions.
在大多数操作系统中,返回值成为流程退出时返回的值。根据约定,返回值为零表示正常退出,而非零值表示不同的异常终止条件。
This value can be tested by most command shells. For instance, in bash, the $?
variable holds the return code of the last program. Also, its &&
and ||
operators determine whether to execute the right hand side, based on whether the left hand side signal a normal exit or not:
这个值可以被大多数命令shell测试。例如,在bash中,$?变量保存上一个程序的返回代码。同时,它和||运算符决定是否执行右手边,基于左手边信号是否正常出口:
# Fetch the images, and only process them if the fetch succeeded (return code 0).
fetch-images && process-images
#4
2
In command line environment, the return value signifies success or failure of the program run. This way you can share some status information with the caller. Zero is reserved to be success in Unix.
在命令行环境中,返回值表示程序运行的成功或失败。通过这种方式,您可以与调用者共享一些状态信息。Zero在Unix中是成功的。
#1
11
It's the exit status. It's typically used to signal to the OS whether the process was successful or not in whatever it was doing.
它的退出状态。它通常用于向操作系统发出信号,表明该过程在其所做的任何事情中是否成功。
#2
4
It indicates the execution status of the program. Usually zero means it went fine.
它指示程序的执行状态。通常0表示一切正常。
#3
3
On most operating systems, the return value becomes the value returned from the process when it exits. By convention, a return value of zero signifies a normal exit, while non-zero values signify different abnormal termination conditions.
在大多数操作系统中,返回值成为流程退出时返回的值。根据约定,返回值为零表示正常退出,而非零值表示不同的异常终止条件。
This value can be tested by most command shells. For instance, in bash, the $?
variable holds the return code of the last program. Also, its &&
and ||
operators determine whether to execute the right hand side, based on whether the left hand side signal a normal exit or not:
这个值可以被大多数命令shell测试。例如,在bash中,$?变量保存上一个程序的返回代码。同时,它和||运算符决定是否执行右手边,基于左手边信号是否正常出口:
# Fetch the images, and only process them if the fetch succeeded (return code 0).
fetch-images && process-images
#4
2
In command line environment, the return value signifies success or failure of the program run. This way you can share some status information with the caller. Zero is reserved to be success in Unix.
在命令行环境中,返回值表示程序运行的成功或失败。通过这种方式,您可以与调用者共享一些状态信息。Zero在Unix中是成功的。