C库宏错误号(errno)

#include <stdio.h>
#include <errno.h>
#include <string.h>

extern int errno ;

int main () {
   FILE *fp;

   fp = fopen("file.txt", "r");
   if( fp == NULL ) {
      fprintf(stderr, "Value of errno: %d/n", errno);
      fprintf(stderr, "Error opening file: %s/n", strerror(errno));
   } else {
      fclose(fp);
   }

   return(0);
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/265185.html

(0)
上一篇 2022年6月7日 19:14
下一篇 2022年6月7日 19:14

相关推荐

发表回复

登录后才能评论