The difference between break, continue, return, and exit in a looping structure

Source: Internet
Author: User
Tags exit in

1.break statements

The use of a break statement is primarily a switch statement and a looping structure. Break statement, exit the loop directly and execute the first statement below the loop structure. If a break statement is used in a multiple nested loop, when the break statement is executed, the loop structure in which it resides is exited, and the outer layer loop has no effect.

2.continue statements

The continue statement does not really exit the loop, but only ends the execution of the loop, so pay attention to this when using continue.

3.return statements

If a return statement is encountered in the program, then Caffrey exits the execution of the function, bounces back to the function's call, and, if it is the main () function, ends the entire program running.

4.exit statements

The most important difference between the exit () function and the return statement is that calling the Exit function ends the current process, deleting the memory space occupied by the child process, and passing the return information to the parent process. When the argument in exit () is 0 o'clock, the exit is normal, the other return value indicates an abnormal exit, and the exit () function means that the process is finished.

The difference between break, continue, return, and exit in a looping structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.