跳轉到內容

C 程式設計/string.h/strerror

來自華夏公益教科書,自由的教科書

字串錯誤函式,strerror,是一個 C/C++ 函式,它將錯誤程式碼(通常儲存在全域性變數 errno 中)轉換為人類可讀的錯誤訊息。

strerror 函式在 IEEE Std 1003.1(也稱為 POSIX 1)中定義。

可重入性

[編輯 | 編輯原始碼]

strerror 函式不可重入。有關該函式的可重入版本,請參見 strerror r。

#include <string.h>
char* strerror(int errnum);

該函式生成並報告一個 C 樣式字串,其中包含從傳遞的錯誤程式碼 errnum 派生的錯誤訊息。

另請參見

[編輯 | 編輯原始碼]
  • strerror r
  • perror

參考文獻

[編輯 | 編輯原始碼]
  1. strerror by OpenGroup
[編輯 | 編輯原始碼]
華夏公益教科書