共用方式為


_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 參數中指定了無效的目錄名稱,就會發生失敗。

注意事項注意事項

不需要針對 _tempnam_dbg 和 _wtempnam_dbg 配置的指標呼叫 free (或 free_dbg)。

備註

_tempnam_dbg 和 _wtempnam_dbg 函式與 _tempnam 和 _wtempnam 相同,唯一不同的是當定義 _DEBUG 時,若 NULL 是作為第一個參數進行傳遞,這些函式會使用偵錯版本的 malloc 和 _malloc_dbg 來配置記憶體。 如需詳細資訊,請參閱_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

概念

堆積配置函式的偵錯版本