Sep 25, 2019 In the above command, -h doesn't mean 'help', but 'human-readable'. Some commands use this convention to display file / disk sizes with K for kilobytes, G for gigabytes, and so on, instead of writing out a gigantic integer number of bytes. Du shows file space usage for a particular directory and its subdirectories. The parameter is an integer status code that is passed back to the invoking shell as the exit status of the process. Exit itself should exit the process an clean up any open resources that your process is using.
- C-Free is an IDE not a compiler and it won't get you around the problem. (And as IDEs go, it's not even all that good.) Neither Vista nor 7 allow full screen consoles anymore.
- The C library function void exit(int status) terminates the calling process immediately. Any open file descriptors belonging to the process are closed and any children of the process are inherited by process 1, init, and the process parent is sent a SIGCHLD signal.
The break statement ends execution of the nearest enclosing loop or conditional statement in which it appears. Control passes to the statement that follows the end of the statement, if any.
Syntax
Remarks
The break statement is used with the conditional switch statement and with the do, for, and while loop statements.
In a switch statement, the break statement causes the program to execute the next statement outside the switch statement. Without a break statement, every statement from the matched case label to the end of the switch statement, including the default clause, is executed.
In loops, the break statement ends execution of the nearest enclosing do, for, or while statement. Control passes to the statement that follows the ended statement, if any.
Within nested statements, the break statement ends only the do, for, switch, or while statement that immediately encloses it. You can use a return or goto statement to transfer control from more deeply nested structures.
Example
The following code shows how to use the break statement in a for loop.
The following code shows how to use break in a while loop and a do loop.
The following code shows how to use break in a switch statement. You must use break in every case if you want to handle each case separately; if you do not use break, the code execution falls through to the next case.
See also
Jump Statements
Keywords
continue Statement
-->Keywords
continue Statement
In C++, you can exit a program in these ways:
- Call the exit function.
- Call the abort function.
- Execute a return statement from
main
.
exit function
The exit function, declared in <stdlib.h>, terminates a C++ program. The value supplied as an argument to
exit
is returned to the operating system as the program's return code or exit code. By convention, a return code of zero means that the program completed successfully. You can use the constants EXIT_FAILURE and EXIT_SUCCESS, also defined in <stdlib.h>, to indicate success or failure of your program.Issuing a return statement from the
main
function is equivalent to calling the exit
function with the return value as its argument.abort function
The abort function, also declared in the standard include file <stdlib.h>, terminates a C++ program. The difference between
exit
and abort
is that exit
allows the C++ run-time termination processing to take place (global object destructors will be called), whereas abort
terminates the program immediately. The abort
function bypasses the normal destruction process for initialized global static objects. It also bypasses any special processing that was specified using the atexit function.atexit function
Use the atexit function to specify actions that execute prior to program termination. No global static objects initialized prior to the call to atexit are destroyed prior to execution of the exit-processing function.
return statement in main
Issuing a return statement from
main
is functionally equivalent to calling the exit
function. Consider the following example:The
exit
and return statements in the preceding example are functionally identical. However, C++ requires that functions that have return types other than void return a value. The return statement allows you to return a value from main
.Destruction of static objects
Dev C++ Online
When you call
exit
or execute a return statement from main
, static objects are destroyed in the reverse order of their initialization (after the call to atexit
if one exists). The following example shows how such initialization and cleanup works.Exit Command Prompt
Example
In the following example, the static objects
sd1
and sd2
are created and initialized before entry to main
. After this program terminates using the return statement, first sd2
is destroyed and then sd1
. The destructor for the ShowData
class closes the files associated with these static objects.Another way to write this code is to declare the
ShowData
objects with block scope, allowing them to be destroyed when they go out of scope: