CARVIEW |
Select Language
HTTP/2 200
content-type: text/html; charset=UTF-8
content-length: 16006
date: Sun, 27 Jul 2025 20:37:52 GMT
server: Apache/2.4.62 (Ubuntu)
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
strict-transport-security: max-age=63072000; includeSubDomains
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS, PATCH
access-control-allow-headers: x-student-id, Authorization, Content-Type, X-Requested-With, Accept, Origin, X-HTTP-Method-Override
access-control-allow-credentials: true
access-control-max-age: 86400
access-control-expose-headers: Accept-Ranges, Content-Encoding, Content-Length, Content-Range
x-device-type: desktop
content-encoding: gzip
x-xss-protection: 1; mode=block
cache-control: max-age=6048000, public
vary: Origin,Accept-Encoding
x-cache: Miss from cloudfront
via: 1.1 d43494f195e4e3dd7202dfa9e17d6efe.cloudfront.net (CloudFront)
x-amz-cf-pop: BOM78-P9
x-amz-cf-id: UpD_ot5hJwnXycVqcfEfzAuE1NVwqO9wtinnqinmKoLcalandkRc1A==
C Standard Library strerror Function

- C Library - Home
- C Library - <assert.h>
- C Library - <complex.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <fenv.h>
- C Library - <float.h>
- C Library - <inttypes.h>
- C Library - <iso646.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdalign.h>
- C Library - <stdarg.h>
- C Library - <stdbool.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <tgmath.h>
- C Library - <time.h>
- C Library - <wctype.h>
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library - strerror() function
The C library strerror() function takes one parameter that searches an internal array for the error number which is errnum and returns a pointer to an error message string. The error strings produced by strerror depend on the developing platform and compiler.
Syntax
Following is the syntax of the C library strerror() function −
char *strerror(int errnum)
Parameters
This function accepts only a single parameter.
- errnum − This is the error number, usually errno.
Return Value
This function returns a pointer to the error string describing error errnum.
Example 1
Following is the C library program that demonstrates the usage of strerror() function.
#include <stdio.h> #include <string.h> #include <errno.h> int main () { FILE *fp; fp = fopen("file.txt","r"); if( fp == NULL ) { printf("Error: %s\n", strerror(errno)); } return(0); }
Output
On executing the above program, it will produce result like we are accessing to open a file but the file doesn't exists −
Error: No such file or directory
Advertisements