Using errno with strerror()
Instead of looking up every possible errno macro and figuring out which ones apply and what they mean, it's easier to use a function called strerror()
. This function converts the errno
code into a readable message. Using strerror()
is much faster than implementing everything ourselves. It's a lot safer, too, since there's less of a risk that we mess something up. Whenever there's a function available to ease the manual work for us, we should use it.
Do note that this function is meant to convert the errno
macro into a readable error message. If we want to handle a particular error in some specific way, we still need to use the actual errno
value.
Getting ready
The requirements from the previous recipe apply to this recipe. This means we need the GCC compiler, the Make tool (along with the Makefile), and the manual pages.
How to do it…
In this recipe, we'll continue developing our own version of touch
. We&apos...