perror
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <stdio.h>
|
||
| void perror( const char *s ); |
||
打印到stderrnull结尾的字符串的内容所指向的
s(除非s是一个空指针),其次是两个字符": ",其次是实现定义的错误消息描述当前存储在系统变量中的错误代码errno(strerror(errno)的输出相同的),其次是'\n'.Original:
Prints to stderr the contents of the null-terminated character string pointed to by
s (unless s is a null pointer), followed by the two characters ": ", followed by the implementation-defined error message describing the error code currently stored in the system variable errno (identical to the output of strerror(errno)), followed by '\n'.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 参数
| s | - | 指针指向一个空结束的字符串说明消息
Original: pointer to a null-terminated string with explanatory message The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 返回值
(无)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 为例
#include <fcntl.h> #include <stdio.h> int main() { if (open("non_existent", O_RDONLY) == -1) { perror("open()"); } }
Output:
open(): No such file or directory
[编辑] 另请参阅
| 返回一个给定的错误代码的文本版本 Original: returns a text version of a given error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
| C++ documentation for perror
| |