In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what is the difference between return, exit and abort in C language. The content of the article is of high quality, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.
In general, in C, you exit a program with return, if in the main function, return calls the exit function after cleaning up local objects.
In contrast to return, exit does not destroy local objects, but all static and global objects, empties buffers, and closes IO channels. The function defined by atexit() is called before termination.
atexit is also in stdlib.h and its declarative formula is
int atexit(void (*func)(void))
When the program terminates, the function pointer func is called.
//atexit.c#include #include void funcA (){ printf("call from atexit\n");}int main (){ atexit(funcA); //Register funcA as an abort function printf("exiting...\ n"); return 0;}
The test results are as follows:
>gcc atexit.c
>a.exe
exiting...
call from atexit
If you want to exit the program without doing anything, you can use abort () to insert abort(); before return 0, and the output will be as follows, without calling funcA.
>a.exe
exiting...
What is the difference between return, exit and abort in C language? I hope the above content can be of some help to everyone and learn more. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.