Print file operation error message
In the file operation, you will encounter errors such as insufficient permissions, files cannot be found, and you can set error capture statements and display errors in your program. Error trapping and error output are implemented using the error number and Streero.
Function Prototypes:
char *streeor (int errnum);
Header file
#include <string.h>
#include <errno.h>
Error codes for printing file operations machine information:
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main (void)
{
int i = 0;
for (i=0; i <; i++)
{
printf ("errno:%d", I);
printf ("message:%s\n", strerror (i));
}
return 0;
}
[Email protected] exercise]$./error
errno:0 Message:success
Errno:1 Message:operation not permitted
Errno:2 message:no such file or directory
Errno:3 Message:no Such process
Errno:4 message:interrupted System call
Errno:5 message:input/output Error
Errno:6 Message:no such device or address
Errno:7 message:argument list too long
Errno:8 message:exec Format Error
Errno:9 Message:bad File Descriptor
Errno:10 Message:no Child Processes
Errno:11 Message:resource temporarily unavailable
Errno:12 Message:cannot Allocate Memory
Errno:13 Message:permission denied
Errno:14 Message:bad Address
Errno:15 Message:block Device required
Errno:16 Message:device or resource busy
Errno:17 Message:file exists
Errno:18 message:invalid Cross-device Link
Errno:19 Message:no such device
Errno:20 Message:not a directory
errno:21 Message:is a directory
errno:22 message:invalid argument
errno:23 Message:too Many open files in system
errno:24 Message:too many open files
ERRNO:25 message:inappropriate IOCTL for device
errno:26 message:text File Busy
Errno:27 Message:file too large
Errno:28 Message:no space left on device
errno:29 Message:illegal Seek
errno:30 message:read-only File System
Errno:31 Message:too Many links
ERRNO:32 Message:broken Pipe
Errno:33 message:numerical argument out of domain
LINUXC file and directory print file operation error message