Error handling in C
Important things - errno and perror. errno is an int in errno.h, and it’s set to various error codes if some function exits with an error. It’s zero otherwise. Check this out:
| |
You can find examples in the man pages of strtol, pipe, etc. Keep in mind that libraries don’t reset errno on success.
Using error codes is… Not that convenient. In Go it’s cooler!
See also Error handling.