#include <stdio.h>
#include <string.h> //strerror 必需
#include <errno.h> //errno必需
int main()
{
FILE *fp = fopen("nofile.txt, "r""); //没有这个文件,打开出错
if(fp == NULL)
{
printf("%s:%d", strerror(errno), errno);
}
return 0;
}
结果:
No such file or directory:2