Copyright statement: reprinted in the form of hyperlink to indicate the original source and author information and this statement http://www.blogbus.com/wzgyantai-logs/24470871.html
When the C api function in linux encounters an exception, the errno variable (which must include errno. h) assign an integer. Different values indicate different meanings. You can view the cause of the error by checking the value, in actual programming, this solution solves many seemingly inexplicable problems. However, errno is a number, and the specific meaning must be read in errno. h. It is very tedious to check every time. The following methods can be used to conveniently obtain error information:
(1) void perror (const char * s)
Function Description
Perror () is used to output the cause of the previous function error to the standard error (stderr). The string indicated by parameter s is printed first, followed by the error cause string. The cause of this error is determined based on the value of the global variable errno.
(2) char * strerror (int errno)
Convert the error code to a string error message. You can combine the string and other information and output it to the user interface, for example
Fprintf (stderr, "error in CreateProcess % s, Process ID % d", strerror (errno), processID)
Note: Assume processID is an acquired integer ID.
(3) printf ("% m", errno );