std::freopen
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Definido no cabeçalho <cstdio>
|
||
FILE *freopen( const char *filename, const char *mode, FILE *stream ); |
||
Reatribui um
stream córrego existente para um arquivo diferente, identificado por filenameusing modo especificado. mode é usado para determinar o modo de acesso novo arquivo. 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.
You can help to correct and verify the translation. Click here for instructions.
Parâmetros
| filename | - | Nome do arquivo para associar o fluxo de arquivo
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 | - | terminada em nulo cadeia de caracteres que determina o modo de acesso do novo arquivo
Original: null-terminated character string determining 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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stream | - | o fluxo de arquivos para modificar
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. |
Valor de retorno
stream no sucesso NULL, em caso de falhaOriginal:
stream on success, NULL on failureThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Exemplo
O código a seguir redireciona
stdout para um arquivo
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.
You can help to correct and verify the translation. Click here for instructions.
#include <cstdio>
int main()
{
std::printf("stdout is printed to console");
std::freopen("redir.txt", "w", stdout);
std::printf("stdout is redirected to a file")
std::fclose(stdout);
}
Saída:
stdout is printed to console
Veja também
abre um arquivo 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. (função) | |
fecha um arquivo 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. (função) | |
Documentação C para freopen
|