©
Dokumen ini menggunakanManual laman web PHP CinaLepaskan
|
在头文件 |
|
|
|---|---|---|
|
void perror(const char * s); |
|
|
打印到stderr由s(由s空指针指向的)以空字符结尾的字符串的内容,后跟两个字符": ",后面跟着实现定义的错误消息,描述当前存储在系统变量中的错误代码errno(与输出strerror(errno)),然后'\n'。
|
s |
- |
指向带有解释性消息的以空字符结尾的字符串 |
|---|
(none).
#includeint main(void){ FILE* f = fopen("non_existent", "r"); if (f == NULL) { perror("open()"); } else { fclose(f); }}
输出:
open(): No such file or directory
C11 standard (ISO/IEC 9899:2011):
7.21.10.4 The perror function (p: 339)
C99 standard (ISO/IEC 9899:1999):
7.19.10.4 The perror function (p: 305)
C89/C90 standard (ISO/IEC 9899:1990):
4.9.10.4 The perror function