Translating errno Error Codes to Text

To translate an error code to its verbal description, use the function strerror(). strerror() is declared in as follows:

 char * strerror(int errcode);

The function takes an error code and returns a statically allocated char array describing that code. Remember that subsequent calls to strerror() overwrite the description string. Therefore, you should copy it to a local buffer unless you intend to use it immediately. In the following example, strerror() translates the current errno code to a string which is then printed on the user

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: