Center 7.5 Install Tomcat+JDK+MySQL (Simple Installation of YUM)

2023-01-21   ES  

A function is best to have a return value.

Generally default function return value is 0 indicating that the program is running successfully. When the function return value is 1, it means that the function is running an error.

To declare the function type, you can write the type before the function name. Just like when a variable is declared, the keyword Return makes the function return the value followed behind the keyword to the call function.

can return a value of a variable, or you can return a value of an expression

c is to tell the value of the variable or function of the variable or function of the recipient of the function,

If there is a statement Return 20 in a function a, then when the variable of another function is called out of this function, the value of the return will be It’s 20.

Of course Return can also return variables, pointers can be used as a function statement is b = 18; return b; then use y = b (), which is equal to 18

RETURN is generally placed in the last position of the function. Since the system executes Return, the function will be jumped out, and the subsequent content will not be executed.


Some summary of Return in C language is Return

TheC++predetermined statement, it provides a magnification of the planting function execution.
When the Return statement provides a value, this value becomes the return value of the function.
When it comes to Return, it is necessary to mention the definition of the main function. Below is the information found from the Internet, digestive, and understand the understanding of the return value in the main function. Many people even some people on the market Books use void main (), which is actually wrong. Void main () has never been defined in C/C ++. The father of C ++, Bjarne Stroustrup, clearly wrote the definition void main () { / * … * … * /} is not and never has ben C ++ in his homepage. () Never exist in C ++ c). Let me talk about the definition of the main function in the C and C ++ standards. 1. c89, main () is acceptable. Brian W. Kernighan and Dennis M. Ritchie The C Programming Language 2E (“Second Edition of Cross Program Design Language”) uses main (). However, in the latest C99 standards, only the following two definition methods are correct: int main (void) Int main (int ARGC, char *argv []) (Reference: ISO/IEC 9899: 1999 (E) Programming Languages – C Program Startup) Of course, we can also make a little change. For example: char *argv [] can be written as char ** argv; Argv and ARGC can be changed to other variable names (such as Intval and Charval), but must meet the name rules of variables.
If you do not need to obtain the parameters from the command line, use Int main (void); otherwise, please use Int main (int ARGC, Char *argv []). The return value type of the main function must be int, so that the return value can pass to the activator of the program (such as the operating system).
If the Main function did not write a RETURN statement at the end, the C99 stipulates that the compiler should automatically in the generated target file (such as EXE file)
Add Return 0;, indicates that the program exits normally
. However, I still recommend that you add Return statements at the end of the main function. Although there is no need, this is a good habit. Note that VC6 will not add Return 0 to the target file; probably because VC6 is a product of 1998, so it does not support this feature. Now I understand why I suggest you better add a Return statement! However, GCC3.2 (C compilers under Linux) add Return 0 to the generated target file; 2. The definition of the following two main functions is defined in C ++ C ++ 98: int main () int map (int ARGC, Char *ARGV []) (Reference: ISO/IEC 14882 (1998-9-01) Programming Languages – C ++ 3.6 START and Termination) int map is equivalent to the int mail (void) in C99; the use of int mail (int argc, char *argv []) is also the same as defined in C99. Similarly, the return value type of the main function must also be int. If the RETURN statement is not written at the end of the main function, C ++ 98 specifies that the compiler should automatically add Return 0 to the generated target file. Similarly, VC6 does not support this feature, but G ++ 3.2 (C ++ compiler) supports. 3. About VOID Main In C and C ++, the function prototype that does not receive any parameters and does not return any information is “VOID FOO (VOID);”. It may be because of this, so many people mistakenly believe that the main game (void) can be defined when the program is not required to return the value. However, this is wrong! The return value of the main function should be defined as an INT type, and both C and C ++ standards are specified. Although in some compilers, VOID Main can compile (such as VC6), not all compilers support VOID Main, because Void Main has never been defined in the standard. If the return value of the main function in G ++ 3.2 is not an INT type, it will not be compiled at all. GCC3.2 will issue a warning. So, if you think your program has a good portability, please use Int main. 4. 4..

The return value of the
return value Main function is used to illustrate the exit state of the program. If you return 0, it means that the program exits normally, otherwise the program is abnormal exit.
Below we do a small experiment in the WinXP environment. First compile the following program: int main (void) {Return 0;} and then open the “
command prompt
“, run the compiled executable file just compiled in the command line, and then enter” Echo %ErrorLevel %”, Enter, you can see that the return value of the program is 0. If you enter “A && DIR”, the folder and files in the current directory will be listed. But if you change it to “Return -1”, or other non -0 values, then enter “A && Dir” after re -compilation, then enter “A && Dir”, then DIR does not execute. Because && means: if the procedure in front of && will continue to execute the procedures behind &&, otherwise it will not be executed. That is to say, using the return value of the program, we can control whether the next program should be performed. . This is the benefit of int service. If you are interested, you can also change the return value type of the main function to a non -int type (such as Float), and then compile “A && Dir” Think of that situation. By the way, if you enter A || DIR, it means that if A abnormally exits, execute DIR. 5. Then intmain (INTARGC, Char*ARGV [], Char*ENVP []) What? This is certainly not a definition in the standard C! Char*ENVP [] is an extension function provided by some compilers for the system
Environment variables

twenty four# . Because it is not a standard, not all compilers support, so the transplantability is poor and it is not recommended. Here, you should understand why the main function is defined as an int return type, and there is RETURN 0 in the function body; this statement. Let’s talk about my understanding of Return’s application. As long as the return value of a function is digital, then you can return 0 (that is, Return 0). In fact, there is no problem you return. Under normal circumstances, the functions made by C ++ are required to return a value. When the function is executed normally and the purpose is achieved in general, then it returns 0 to indicate the correct call. The notification is not wrong; if

function call
Error, or if it is not executed in general, then return 1 to inform the main function of the function to adopt a response strategy; It is negative), so the function can return different values to what abnormal or errors occur in the main adjustment function. This situation is generally used in the case where the functional function is poorly independent. Therefore, generally do not encourage the function to return the function as VOID, at least the return should be int, and the end of the Return 0. sentence: int FUNC If you encounter the Return statement, the program will return the next statement execution that calls the function, that is, the execution of the function jumping out of the function, and return to the original place to continue executing. But if you encounter the Return statement in the main function, the entire program will stop and exit the execution of the program. If you define a function back type, you can think of the following call: int Func () {int value; … … … Return value;} int main () {int intvalue; intvalue = func (); … … Teturn 0;} What is the specific content behind the Return statement, this requires the specific situation to analyze it: (1) In the function of the return type is the function of the return, it should be the value of the CHAR type; (2)
In the back type is an int function, if you want to stop the call of the function, it is best to be 0
; Others depend on your purpose, as long as it is an INT type (3) In the function of the return type is the function of the structural type, the return should be an instance object of the structure. In short,

function defines why the return type, which should be the value of the corresponding type after returning.


Related Posts

pHP related knowledge to learn about it (1)

Spring-IOC container-Keke Teacher

Openark installation tutorial

React’s eCharts realizes gradient and zoomed in Welkin

Center 7.5 Install Tomcat+JDK+MySQL (Simple Installation of YUM)

Random Posts

The traffic of port 80 was forwarded to


Renren Houxun Router TTL flashing

ES6 Module (Export and Export Default)

Use myBatis-Generator to automatically generate code