当前位置:网站首页>Errno perrno and strerrno
Errno perrno and strerrno
2022-06-25 14:59:00 【qq_ twenty-three million nine hundred and fifty-three thousand 】
errno
The header file <errno.h>
errno It's a by POSIX and ISO C Symbols defined by the standard . When an error occurs in a system call or library function , For example, when opening a nonexistent file in an institutional way , Its value will be changed , according to errno The difference in value , We can see what went wrong with the program .
Such as error code errno by 12 The error is Cannot allocate memory
perror
The function prototype :void perror(const char *s)
Function description : Output the cause of the error in the previous function to the standard error (stderr), Parameters s The string pointed to will be printed out first , Then print the real error output , Such as perror(“ABC:”), String is ABC:Cannot allocate memory
strerror
The function prototype :void strerror(int errno)
Function description : Convert the error code to a string error message , This string and other information can be combined and output to the user interface , Such as printf(“errno :%d, %s”, errno, strerror(errno)) The output value is errno:12,Cannot allocate memory
matters needing attention
1, If the system call or library function is executed correctly ,errno The value of is not cleared , If you execute a function A There was a mistake errno Be changed , Next, execute the function directly B, If the function B If executed correctly ,errno Also keep functions A The value set when an error occurs .
2, The system call or library function is executed correctly , There is no guarantee that errno The value of will not be changed
3, All error numbers are non - 0 Of
Sum up : When needed errno To determine whether the function is executed correctly , take errno Set up 0, At the end of function execution , Determine whether the function is executed correctly , When an execution error occurs , Follow up errno To determine exactly what went wrong .
边栏推荐
- 开餐馆
- Installing QT plug-in in Visual Studio
- What moment makes you think there is a bug in the world?
- Open a restaurant
- Basic knowledge of pointer
- C language LNK2019 unresolved external symbols_ Main error
- Golang channel reading data
- Js- get the mouse coordinates and follow them
- QQ love talk candy love talk content acquisition and storage
- [Ocean University of China] Data Sharing for retest of initial Examination
猜你喜欢

Learning notes on February 18, 2022 (C language)

Design and implementation of timer

Dynamic memory allocation

1090.Phone List

Uniapp icon configuration

Ideal L9 in the eyes of the post-90s: the simplest product philosophy, creating the most popular products

【中國海洋大學】考研初試複試資料分享
![[Ocean University of China] Data Sharing for retest of initial Examination](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[Ocean University of China] Data Sharing for retest of initial Examination

15 -- 最接近原点的 K 个点

关于win10 版本kicad 卡死的问题, 版本6.x
随机推荐
Jaspersoft studio adding MySQL database configuration
网上办理股票开户安全吗?
Kubernetes understands kubectl/ debugging
Function of getinstance() method
电源自动测试系统NSAT-8000,精准高速可靠的电源测试设备
HMS core machine learning service realizes simultaneous interpretation, supports Chinese-English translation and multiple voice broadcast
【Try to Hack】vulnhub DC1
全国首例,中国电信 5G 井下人员定位项目正式商用:可实时跟踪位置,保障作业安全
Ubuntu 20.04 installing mysql8.0 and modifying the MySQL password
Custom structure type
One question per day, a classic simulation question
System Verilog - data type
Qmake uses toplevel or topbuilddir
Use Matplotlib to draw a line chart
Common classes in QT
(translation) json-rpc 2.0 specification (Chinese version)
Qlogsystem log system configuration use
Study notes of cmake
Extend JS copy content to clipboard
[deep learning] multi task learning of multiple datasets data sets missing labels