User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:string.h:strerror

strerror

#include <string.h>
//#include <windows.h> /* uncomment this for Windows */
char *strerror(int errnum);

Description

returns a pointer to a string that describes the error code passed in the argument errnum

compile this example with the compiler flag -lm

strerror C Example Code

/* 
 * strcspn c example code
 * http://code-reference.com/c/string.h/strerror
 */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <math.h>
 
int main ( void ) {
 
double i;
i = sqrt(-1);
printf("sqrt(-1)=%f\n",i);
printf("%s\n", strerror(errno));
return 0;
}

Output of strerror example

  sqrt(-1)=-nan
  Numerical argument out of domain
advertising
c/string.h/strerror.txt · Last modified: 2013/02/17 00:49 by Daniel Gohlke

Impressum Datenschutz

Creating directory /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021 failed
Writing /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021/misc_data.ser failed
Creating directory /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021 failed
Writing /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021/ip.ser failed
Creating directory /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021 failed
Writing /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021/pages.ser failed
Creating directory /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021 failed
Writing /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021/ua.ser failed
Creating directory /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021 failed
Writing /kunden/homepages/20/d423760527/htdocs/cpp/data/meta/quickstats/10_2021/page_users.ser failed