共用方式為


_tempnam_dbg _wtempnam_dbg

函式版本的_tempnam、 _wtempnam、 tmpnam、 _wtmpnam所使用的偵錯版本malloc, _malloc_dbg

char *_tempnam_dbg(
   const char *dir,
   const char *prefix,
   int blockType,
   const char *filename,
   int linenumber 
);
wchar_t *_wtempnam_dbg(
   const wchar_t *dir,
   const wchar_t *prefix,
   int blockType,
   const char *filename,
   int linenumber 
);

參數

  • dir
    如果沒有任何 TMP 環境變數,或如果 TMP 不是有效的目錄,用在 [檔案名稱的路徑。

  • prefix
    將會附加到名稱所傳回的字串_tempnam。

  • blockType
    要求的記憶體區塊類型: _CLIENT_BLOCK或_NORMAL_BLOCK。

  • filename
    要求配置作業的原始程式檔名稱的指標或NULL。

  • linenumber
    對齊配置操作所要求的位置的原始程式檔中的數字或NULL。

傳回值

每個函式傳回的指標,以產生的名稱或NULL如果發生失敗。 如果沒有指定 TMP 環境變數中,並在無效的目錄名稱,就會發生失敗dir參數。

注意事項注意事項

free(或free_dbg) 並需要調整到足以指標所配置的_tempnam_dbg和_wtempnam_dbg。

備註

_tempnam_dbg和_wtempnam_dbg函式是等於_tempnam和_wtempnam差異在於,當_DEBUG是定義,這些函式使用的偵錯版本malloc和_malloc_dbg、 配置記憶體,如果NULL的第一個參數傳遞。 如需詳細資訊,請參閱 _malloc_dbg

您不需要明確地呼叫這些函式,在大多數情況下。 相反地,您可以在其中定義這個旗標_CRTDBG_MAP_ALLOC。 當_CRTDBG_MAP_ALLOC已定義,會呼叫_tempnam和_wtempnam對應至 「 _tempnam_dbg和_wtempnam_dbg,分別與blockType設定為 [ _NORMAL_BLOCK。 因此,您不需要明確地呼叫這些函式,除非您想要標示為堆積區塊_CLIENT_BLOCK。 如需詳細資訊,請參閱 偵錯堆積上的區塊類型

泛用文字常式對應

TCHAR。H 常式

_UNICODE & 未定義的 _MBCS

定義的 _MBCS

定義 _unicode 之後

_ttempnam_dbg

_tempnam_dbg

_tempnam_dbg

_wtempnam_dbg

需求

常式

所需的標頭

_tempnam_dbg, _wtempnam_dbg

<crtdbg.h>

其他的相容性資訊,請參閱相容性在簡介中。

.NET Framework 對等用法

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

請參閱

參考

_tempnam、 _wtempnam、 tmpnam、 _wtmpnam

資料流 I/O

概念

堆積配置函式的偵錯版本