Error Function C
Contents |
of a library call. The functions strerror and perror give you the standard error message for a given error code; the variable program_invocation_short_name gaussian error function calculator gives you convenient access to the name of the program that encountered print error c the error. Function: char * strerror (int errnum) Preliminary: | MT-Unsafe race:strerror | AS-Unsafe heap i18n | AC-Unsafe inverse error function c mem | See POSIX Safety Concepts. The strerror function maps the error code (see Checking for Errors) specified by the errnum argument to a descriptive error message string. The return
C Error Function Declared Implicitly
value is a pointer to this string. The value errnum normally comes from the variable errno. You should not modify the string returned by strerror. Also, if you make subsequent calls to strerror, the string might be overwritten. (But it’s guaranteed that no library function ever calls strerror behind your back.) The function strerror is declared in string.h. Function: char error.h c * strerror_r (int errnum, char *buf, size_t n) Preliminary: | MT-Safe | AS-Unsafe i18n | AC-Unsafe | See POSIX Safety Concepts. The strerror_r function works like strerror but instead of returning the error message in a statically allocated buffer shared by all threads in the process, it returns a private copy for the thread. This might be either some permanent global data or a message string in the user supplied buffer starting at buf with the length of n bytes. At most n characters are written (including the NUL byte) so it is up to the user to select a buffer large enough. This function should always be used in multi-threaded programs since there is no way to guarantee the string returned by strerror really belongs to the last call of the current thread. The function strerror_r is a GNU extension and it is declared in string.h. Function: void perror (const char *message) Preliminary: | MT-Safe race:stderr | AS-Unsafe corrupt i18n heap lock | AC-Unsafe corrupt lock mem fd | See POSIX Safety Concepts. This function prints a
extern int errno or #define errno definition is used to hold implementation-defined error codes from standard library routines All error codes are positive integers c error codes and are traditionally defined in
C Error Handling Best Practices
condition which occurred; library functions should never clear errno, so if errno is to be checked after a
C Print Error Message Errno
library call, it is the programmer's responsibility to set it to 0 before calling the library routine Error String - strerror char *strerror(int errnum) strerror returns a pointer http://www.gnu.org/s/libc/manual/html_node/Error-Messages.html to the error message string associated with errnum Print Error String - perror void perror(const char *str) perror finds the error message string associated with the global errno variable and prints it, prepended by the text in str and a colon if str is non-null, and followed by a newline, to the standard error file descriptor. List http://icecube.wisc.edu/~dglo/c_class/errfunc.html of Common Error Constants EPERM Operation not permitted ENOENT No such file or directory ESRCH No such process EINTR Interrupted system call EIO I/O error ENXIO No such device or address E2BIG Argument list too long ENOEXEC Exec format error EBADF Bad file descriptor ECHILD No child processes ENOMEM Not enough core EACCES Permission denied EFAULT Bad address ENOTBLK Block device required EBUSY Resource busy EEXIST File exists EXDEV Cross-device link ENODEV No such device ENOTDIR Not a directory EISDIR Is a directory EINVAL Invalid argument ENFILE Too many open files in system EMFILE Too many open files ENOTTY Inappropriate I/O control operation ETXTBSY Text file busy EFBIG File too large ENOSPC No space left on device ESPIPE Illegal seek EROFS Read-only file system EMLINK Too many links EPIPE Broken pipe EDOM Numerical argument out of domain ERANGE Result too large ENOMSG No message of desired type EIDRM Identifier removed ECHRNG Channel number out of range ELNRNG Link number out of range EUNATCH Protocol driver not attached Previous, Next, Index
// additional overloads for integral types Compute error function Returns the error function value for x. Header http://www.cplusplus.com/reference/cmath/erf/
2
3
4
5
6
7
8
9
10
11
12
/* error function erf example */ #include