◐ Shell
clean mode source ↗

std::basic_filebuf::open — cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

std::basic_filebuf<CharT, Traits>* open( const char* s, std::ios_base::openmode mode )

(1)

std::basic_filebuf<CharT, Traits>* open( const std::string& s, std::ios_base::openmode mode )

(2) (depuis C++11)

Ouvre le fichier dont le nom est donné par

Original:

Opens the file whose name is given by

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

1)

le zéro terminal s étroite chaîne d'octets

Original:

the null-terminated narrow byte string s

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

le zéro terminal s.c_str() étroite chaîne d'octets

Original:

the null-terminated narrow byte string s.c_str()

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

comme en appelant std::fopen(s, modestring), où modestring est déterminée comme suit:

Original:

as if by calling std::fopen(s, modestring), where modestring is determined as follows:

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

modestring

Original:

modestring

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

openmode & ~ate
"r" in
"w" out, out|trunc
"a" app, out|app
"r+" out|in
"w+" out|in|trunc
"a+" out|in|app, in|app
"rb" binary|in
"wb" binary|out, binary|out|trunc
"ab" binary|app, binary|out|app
"r+b" binary|out|in
"w+b" binary|out|in|trunc
"a+b" binary|out|in|app, binary|in|app

Si openmode n'est pas l'un des modes énumérés, le open() échoue .

Original:

If openmode is not one of the modes listed, the open() fails.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Si l'opération réussit et ouvert openmode & std::ios_base::ate != 0 (le bit est réglé ate), repositionne la position du fichier à la fin du fichier, comme si en appelant std::fseek(file, 0, SEEK_END). Si le repositionnement échoue, appelle close() et renvoie un pointeur NULL pour indiquer l'échec .

Original:

If the open operation succeeds and openmode & std::ios_base::ate != 0 (the ate bit is set), repositions the file position to the end of file, as if by calling std::fseek(file, 0, SEEK_END). If the repositioning fails, calls close() and returns a null pointer to indicate failure.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Si le fichier associé est déjà ouvert, retourne un pointeur nul tout de suite .

Original:

If the associated file was already open, returns a null pointer right away.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Paramètres

s -

le nom du fichier à ouvrir

Original:

the file name to open

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

openmode -

le mode d'ouverture du fichier, un OU binaire des modes std::ios_base

Original:

the file opening mode, a binary OR of the std::ios_base modes

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Retourne la valeur

*this en cas de succès, un pointeur NULL en cas d'échec .

Original:

*this on success, a null pointer on failure.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Notes

open() est généralement appelée par le constructeur ou la fonction membre open() de std::basic_fstream .

Original:

open() is typically called through the constructor or the open() member function of std::basic_fstream.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Exemple

Voir aussi

checks if the associated file is open
(fonction membre publique) [edit]

le tampon des mises région et ferme le fichier associé

Original:

flushes the put area buffer and closes the associated file

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique) [edit]