在 linuxC中,使用strerror() 和 perror( ) 函數打印相應的錯誤信息,這兩個函數的標準格式說明如下:
#include <string.h>
char *strerror(int errnum);
#include <stdio.h>
void perror(const char *msg)
strerror函數的返回值是一個指向消息字符串的指針,這個消息字符串即爲出錯信息的字符串.
perror 函數沒有返回值,其輸出如下:
"由msg指針指向的字符串" + ":" +errno + "回車換行"