包含要在錯誤訊息本身之前列印的自定義訊息的 C 字串。 如果它是空指標,則不列印前面的自定義訊息,但仍會列印錯誤訊息。 按照慣例,應用程式本身的名稱通常用作引數。
返回值
無
示例
1 2 3 4 5 6 7 8 9 10 11 12 13
/* perror example */
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile=fopen ("unexist.ent","rb");
if (pFile==NULL)
perror ("The following error occurred");
else
fclose (pFile);
return 0;
}
如果檔案unexist.ent不存在,您可能會期望類似這樣的程式輸出
The following error occurred: No such file or directory