[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

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.


0
nerdmike
Asked:
nerdmike
1 Solution
 
nayernaguibCommented:
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
0
 
NopiusCommented:
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 )
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now