CS计算机代考程序代写 Error Handling

Error Handling

Error Handling

Review of Streams
In c / POSIX operating systems all inputs / outputs are made through streams.

All of these can be redirected.
Stream
Stdout Standard output (usually screen)
Stdin Standard input (usually keyboard)
FILE stream File on the hard drive
Stderr Standard Error (usually screen)

Printing to standard error
The most general way to print to standard error is to use fprintf.

The perror function
The function perror gives a simpler way to write to standard out.

perror(“This is an error message: ”);

Error Numbers
The “success” flag at the end of perror is given by the error number

This function returns a string corresponding to the error number.
puts(strerror(errnum)) will print a specific error message.

Important ones:
EDOM (33), domain error
ERANGE (34), range error
EEXIST (17), file exists

Example

/docProps/thumbnail.jpeg