名前空間
変種
操作

std::tmpnam

提供: cppreference.com
< cpp‎ | io‎ | c

 
 
入力/出力ライブラリ
I / Oのマニピュレータ
CスタイルのI / O
バッファ
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(廃止予定)
ストリーム
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象化
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
ファイルI / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
文字列I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
アレイのI / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(廃止予定)
ostrstream(廃止予定)
strstream(廃止予定)
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
エラーカテゴリインターフェース
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
CスタイルのI / O
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファイルアクセス
Original:
File access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
直接入力/出力
Original:
Direct input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fread
fwrite
書式なし入力/出力
Original:
Unformatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
書式付き入力/出力
Original:
Formatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファイル位置付け
Original:
File positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ftell
fgetpos
fseek
fsetpos
rewind
エラー処理
Original:
Error handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
clearerr
feof
ferror
perror
ファイルに対する操作
Original:
Operations on files
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
remove
rename
tmpfile
tmpnam
 
Defined in header <cstdio>
char* tmpnam( char* filename );
現在、既存のファイルを指定していない一意のファイル名を作成し、filenameが指す文字列に格納します。適切な戻り値関数が一意のファイル名のTMP_MAXまで生成することが可能であるが、それらの一部または全部が既に使用中である可能性があり、その結果ではない.
Original:
Creates an unique filename that does not name a currently existing file, and stores it in the character string pointed to by filename. The function is capable of generating up to TMP_MAX of unique filenames, but some or all of them may already be in use, and thus not suitable return values.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

filename -
結果バッファとして使用するために、少なくともL_tmpnamバイトを、保持することが可能な文字配​​列へのポインタ。 NULLが渡された場合は、内部の静的バッファへのポインタが返されます.
Original:
pointer to the character array capable of holding at least L_tmpnam bytes, to be used as a result buffer. If NULL is passed, a pointer to an internal static buffer is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

filenamefilenameNULLなかった場合。そうでなければ内部の静的バッファへのポインタが返されます。適当なファイル名を生成できない場合、NULLが返されます.
Original:
filename if filename was not NULL. Otherwise a pointer to an internal static buffer is returned. If no suitable filename can be generated, NULL is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] ノート

nullポインタの引数で呼び出された場合、この関数はグローバルオブジェクトを変更します。別のスレッドが同時にnullポインタ引数を指定してstd::tmpnam呼び出した場合、その動作はデータの競合が原因で定義されていません.
Original:
When called with null pointer argument, this function modifies a global object. If another thread calls std::tmpnam with null pointer argument at the same time, the behavior is undefined due to a data race.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::tmpnamによって生成された名前が推測することは困難であるが、その名前を持つファイルがモーメントstd::tmpnamリターンと、このプログラムがファイルを作成するために返された名前を使用しようとした一瞬の間に別のプロセスによって作成されている可能性があります。標準関数std::tmpfileとPOSIX関数mkstempはこの問題は発生しません.
Original:
Although the names generated by std::tmpnam are difficult to guess, it is possible that a file with that name is created by another process between the moment std::tmpnam returns and the moment this program attempts to use the returned name to create a file. The standard function std::tmpfile and the POSIX function mkstemp do not have this problem.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <cstdio>
#include <string>
int main()
{
    std::string name1 = std::tmpnam(nullptr);
    std::cout << "temporary file name: " << name1 << '\n';
 
    char name2[L_tmpnam];
    if(std::tmpnam(name2))
        std::cout << "temporary file name: " << name2 << '\n';
}

Possible output:

temporary file name: /tmp/fileDjwifs
temporary file name: /tmp/fileEv2bfW

[編集] も参照してください

作成され、一時的な、自動削除するファイルを開きます
Original:
creates and opens a temporary, auto-removing file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能) [edit]
C documentation for tmpnam