_get_errno

取得目前 errno 全域變數的值。

errno_t _get_errno( 
   int * pValue 
);

參數

  • [] outpValue
    要填滿目前的值為整數的指標errno變數。

傳回值

傳回零,如果執行成功。 錯誤碼錯誤所致。如果pValue是NULL,如所述,無效的參數處理常式被叫用參數驗證。如果執行,則允許繼續執行,這個函式會將errno到EINVAL ,並傳回EINVAL。

備註

可能值的errno Errno.h 中所定義。請參閱errno 常數

範例

// crt_get_errno.c
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <share.h>
#include <errno.h>

int main()
{
   errno_t err;
   int pfh;
   _sopen_s( &pfh, "nonexistent.file", _O_WRONLY, _SH_DENYNO, _S_IWRITE );
   _get_errno( &err );
   printf( "errno = %d\n", err );
   printf( "fyi, ENOENT = %d\n", ENOENT );
}
  

需求

常式

所需的標頭

選擇性標頭

_get_errno

<stdlib.h>

<errno.h>

如需相容性資訊,請參閱相容性在簡介中。

NET Framework 的對等用法

不適用。若要呼叫標準的 c 函式,使用PInvoke。如需詳細資訊,請參閱平台叫用範例

請參閱

參考

_set_errno

errno、 _doserrno、 _sys_errlist 和 _sys_nerr