errno question

I want to be able to print out the string which describes the error number returned

Note this is not the description returned by strerror, I want to get my hands on EXXXXX in string format.

Who is Participating?
It's possible _only_ by defining your own array of strings like:

char *errno_str[]={"OK", "EPERM", "ENOENT", ... };

look to /usr/include/sys/errno.h for all possibilities.
Also there may be name collision where same integer have two names (like EWOULDBLOCK  == EAGAIN )
If you want to print the error number, then you can print the value of errno. It already holds the error number!

  printf( "errno = %d, description: %s\n", errno, strerror(errno));


  Nayer Naguib
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.