perror( )函数定义在stdio.h头文件中,函数原型void
perror
(
const
char
* str );一般用于输出错误原因,参数为字符串。
实例
#include<stdio.h>
int
main(
void
)
{
FILE
*fp;
fp=
fopen
(
"test.txt"
,
"r+"
);
if
(NULL==fp)
{
perror
(
"cann't open text.txt"
);
}
return
0;
}