名前空間
変種
操作

std::tmpfile

提供: 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>
FILE* tmpfile();
ユニークな自動生成されたファイル名で一時ファイルを作成し、開きます。.
Original:
Creates and opens a temporary file with unique auto-generated filename.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファイルは、更新用のバイナリファイル(アクセス·モードを持つstd::fopen"wb+"などによって)として開かれます。少なくともTMP_MAXファイル(この制限をstd::tmpnamと共有されることがあり、さらにFOPEN_MAXによって制限される場合があります)プログラムの存続期間中に開かれることがあります
Original:
The file is opened as binary file for update (as by std::fopen with access mode "wb+"). At least TMP_MAX files may be opened during the lifetime of a program (this limit may be shared with std::tmpnam and may be further limited by FOPEN_MAX)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
プログラムは、例えば、ファイルを閉じた場合std::fcloseを実行することにより、ファイルは自動的に削除されます.
Original:
If the program closes the file, e.g. by executing std::fclose, the file is automatically deleted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
プログラムが正常に終了(std::exitから帰国し、mainを呼び出すことによって、等)した場合、std::tmpfileを呼び出すことによって開かれたすべてのファイルも自動的に削除されます.
Original:
If the program terminates normally (by calling std::exit, returning from main, etc), all files that were opened by calling std::tmpfile are also automatically deleted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
プログラムが異常終了した場合、これらの一時ファイルが削除された場合、それは実装で定義されてい.
Original:
If the program terminates abnormally, it is implementation-defined if these temporary files are deleted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

(なし)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

エラーが発生した場合、関連付けられたファイルストリームまたはNULL
Original:
The associated file stream or NULL if an error has occurred
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] ノート

いくつかの実装では(例えばLinux)、この関数は、実際にファイルシステムからファイルを作成し開き、ただちに削除:削除されたファイルへのオープンファイル記述子は、プログラムで使用されている限り、ファイルは存在しますが、それがあったので削除時に、その名前が他のプロセスがそれを開くことができませんので、任意のディレクトリに表示されません。ファイルディスクリプタがクローズされると、ファイルが占有していたスペースは、ファイルシステムによってクリアされる.
Original:
On some implementations (e.g. Linux), this function actually creates, opens, and immediately deletes the file from the file system: as long as an open file descriptor to a deleted file is held by a program, the file exists, but since it was deleted, its name does not appear in any directory, so that no other process can open it. Once the file descriptor is closed, the space occupied by the file is reclaimed by the filesystem.
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 <cstdlib>
 
int main()
{
    FILE* tmpf = std::tmpfile();
    std::fputs("Hello, world", tmpf);
    std::rewind(tmpf);
    char buf[6];
    std::fgets(buf, sizeof buf, tmpf);
    std::cout << buf << '\n';
 
    // Linux-specific method to display the tmpfile name
    std::system("ls -l /proc/self/fd/3");
}

Possible output:

Hello
lrwx------ 1 user group 64 Jun 27 00:28 /proc/self/fd/3 -> /tmp/tmpfXu58Zi (deleted)

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

一意のファイル名を返します
Original:
returns a unique filename
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 tmpfile