名前空間
変種
操作

freopen

提供: cppreference.com
< c‎ | io

 
 
File input/output
機能します
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.
fopen
freopen
fclose
fflush
直接入力/出力
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 <stdio.h>
FILE *freopen( const char *filename, const char *mode, FILE *stream );
指定したモードをstreamusingによって識別される別のファイルに既存のファイルストリームfilenameを再割り当てします。 modeは、新しいファイル·アクセス·モードを決定するために使用され.
Original:
Reassigns an existing file stream stream to a different file identified by filenameusing specified mode. mode is used to determine the new file access mode.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

filename -
にファイルストリームを関連付けるファイル名
Original:
file name to associate the file stream to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mode -
新しいファイル·アクセス·モードを決定する、NULLで終わる文字列
File access
mode string
Meaning Explanation Action if file
already exists
Action if file
does not exist
"r" read Open a file for reading read from start failure to open
"w" write Create a file for writing destroy contents create new
"a" append Append to a file write to end create new
"r+" read extended Open a file for read/write read from start error
"w+" write extended Create a file for read/write destroy contents create new
"a+" append extended Open a file for read/write write to end create new
File access mode flag "b" can optionally be specified to open a file in binary mode. This flag has effect only on Windows systems.
On the append file access modes, data is written to the end of the file regardless of the current position of the file position indicator.
Original:
null-terminated character string determining new file access mode
File access
mode string
Meaning Explanation Action if file
already exists
Action if file
does not exist
"r" read Open a file for reading read from start failure to open
"w" write Create a file for writing destroy contents create new
"a" append Append to a file write to end create new
"r+" read extended Open a file for read/write read from start error
"w+" write extended Create a file for read/write destroy contents create new
"a+" append extended Open a file for read/write write to end create new
File access mode flag "b" can optionally be specified to open a file in binary mode. This flag has effect only on Windows systems.
On the append file access modes, data is written to the end of the file regardless of the current position of the file position indicator.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
stream -
ファイルストリームを変更する場合があります
Original:
the file stream to modify
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

成功した場合にstream、失敗した場合にNULL
Original:
stream on success, NULL on failure
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

次のコードは、ファイルにリダイレクトしstdout
Original:
The following code redirects stdout to a file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <stdio.h>
 
int main()
{
    printf("stdout is printed to console");
    freopen("redir.txt", "w", stdout);
    printf("Stdout is redirected to a file");
    fclose(stdout);
}

Output:

stdout is printed to console

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

ファイルを開きます
Original:
opens a file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能) [edit]
ファイルを閉じます
Original:
closes a 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 freopen