Register | Sing In

New posts

Stacks in C programming Linked Lists in C programming File Input/Output in C programming Check prime numbers in C Programming C Programming Enumeration C Programming Union

Archives

2013-10 2013-09 2013-08

Function strerror in C programming

September 19, 2013 Posted by: GPA Views: 26754 0 comments

Problem

Function strerror in C programming.

Solution

In this section, we tell how you can use function strerror() of header file <string.h>.

Declaration:

char *strerror(int errornumber);

This function takes integer value as input parameter and returns a pointer to the string (error message). Program below demonstrates all errors from 0 to 42.

Example:



#include <stdio.h>
#include <stdlib.h>
#include <string.h>//for function strerror
//main function
int main(int argc, char *argv[])
{
printf("globalproganswer.com\n");
int i;
//show all errors from 0 to 42
for(i=0;i<43;i++){
char* errorMessage=strerror(i);//call function strerror
printf("Error message with input parameter %d is: %s\n",i,errorMessage);
}
printf("\n\n");//new line
system("PAUSE");//delay
return 0;
}

Output

Function strerror

Download this example

0 Comments...

Leave a Reply

Please, Sing In to leave a Reply for this material.



Online Chat

LiveZilla Live Help

Popular posts

Function strtok in C programming Check prime numbers in C Programming C Programming Union Linked Lists in C programming File Input/Output in C programming C Programming Enumeration

RSS-subscribe

New materials

Subscribe