About 143,000 results
Open links in new tab
  1. c - Use of exit() function - Stack Overflow

    Mar 11, 2010 · <iostream.h> is specific to C++, and is not related to <stdlib.h>, the header that's actually needed. The only portable arguments to the exit function are 0, EXIT_SUCCESS, and …

  2. c++ - How to break out of a function - Stack Overflow

    Jun 10, 2011 · Use return to exit from a function. Use break to quit the loop. Note: "Using break will quit the loop, whereas return will actually complete the method. So if your goal is to simply …

  3. How do I make a C++ console program exit? - Stack Overflow

    Oct 28, 2010 · Returning a value is optional in C++, but I typically prefer to return EXIT_SUCCESS found in cstdlib (a platform-specific value that indicates the program …

  4. c++ - How do you "break" out of a function? - Stack Overflow

    Feb 17, 2010 · Given a function that returns a value, is it possible to exit the function given a certain condition without returning anything? If so, how can you accomplish this? Example: int …

  5. function - Correct usage of exit() in c++? - Stack Overflow

    Jan 1, 2013 · From main there's no difference in exit(1) or return 1. You use a return/exit value of 0 for success and non 0 for failure. If your subroutine is a library routine, which is used …

  6. How do you run a function on exit in C++ - Stack Overflow

    Feb 22, 2012 · Exit: Since I used exit() in my examples above, care must be taken here. If the function being run is a clean-up function that only needs to run once, perhaps a static variable …

  7. How do you exit from a void function in C++? - Stack Overflow

    Jan 29, 2017 · Note you can always rewrite a function to always return at the bottom, which is a structured programming principle (one point of entry, one point of exit), – Malcolm McLean …

  8. How to end C++ code - Stack Overflow

    May 15, 2015 · Terminating the program without leaving the current block (e.g., by calling the function std::exit(int) (18.5)) does not destroy any objects with automatic storage duration …

  9. Is it safe to call exit() from a C++ function to terminate the …

    Aug 1, 2022 · @Sneftel: For example, the Microsoft docs say "The exit, _Exit and _exit functions terminate the calling process. The exit function calls destructors for thread-local objects, then …

  10. c++ - return statement vs exit () in main () - Stack Overflow

    Some old pre-ANSI compilers might have treated the value returned by main differently from the value passed to exit-- but the standard specifically says, "If the return type of the main function …

Refresh