How to use the strerror(errno) function to interpret the value of errno to error message in C

1 Answer

0 votes
#include <stdio.h>
#include <errno.h>
#include <string.h>
 
int main(void)
{
	FILE *fp;
  
	fp = fopen("abcd.efg", "r");
	if (fp == NULL)
		printf("Error open file abcd.efg: %s\n", strerror(errno));
     
    return 0;
}

 
/* 
run:

Error open file abcd.efg: No such file or directory
 
*/

 



answered Feb 15, 2016 by avibootz

Related questions

2 answers 246 views
1 answer 207 views
1 answer 230 views
1 answer 119 views
119 views asked May 18, 2023 by avibootz
1 answer 201 views
...