std::feof — cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Déclaré dans l'en-tête <cstdio> |
||
|
|
||
Vérifie si la fin du flux de fichier donné a été atteint .
Original:
Checks if the end of the given file stream has been reached.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
| stream | - | le flux de fichier à vérifier Original: the file stream to check The text has been machine-translated via Google Translate. |
Retourne la valeur
Valeur différente de zéro si la fin du flux a été atteinte, sinon 0 .
Original:
Nonzero value if the end of the stream has been reached, otherwise 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Notes
Cette fonction signale que l'état courant tel que rapporté par la plus récente opération E / S, il n'examine pas la source de données associée. Par exemple, si la plus récente d'E / S a été un std::fgetc, qui a retourné le dernier octet d'un fichier, std::feof renvoie une valeur non nulle. Le std::fgetc suivante échoue et modifie l'état de flux de fin-de-fichier. C'est alors seulement std::feof retourne zéro .
Original:
This function only reports the stream state as reported by the most recent I/O operation, it does not examine the associated data source. For example, if the most recent I/O was a std::fgetc, which returned the last byte of a file, std::feof returns non-zero. The next std::fgetc fails and changes the stream state to end-of-file. Only then std::feof returns zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
En utilisation normale, le traitement des flux d'entrée s'arrête sur une erreur; feof et std::ferrror sont ensuite utilisés pour distinguer entre les différentes conditions d'erreur .
Original:
In typical usage, input stream processing stops on any error; feof and std::ferrror are then used to distinguish between different error conditions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Exemple
#include <cstdio> #include <cstdlib> int main() { FILE* fp = std::fopen("test.txt", "r"); if(!fp) { std::perror("File opening failed"); return EXIT_FAILURE; } int c; // note: int, not char, required to handle EOF while ((c = std::fgetc(fp)) != EOF) { // standard C I/O file reading loop std::putchar(c); } if (std::ferror(fp)) std::puts("I/O error when reading"); else if (std::feof(fp)) std::puts("End of file reached successfully"); }
Voir aussi
vérifie si fin de fichier a été atteinte Original: checks if end-of-file has been reached The text has been machine-translated via Google Translate. (fonction membre publique de std::basic_ios) [edit]
| |
efface les erreurs Original: clears errors The text has been machine-translated via Google Translate. (fonction) [edit] | |
affiche une chaîne de caractères correspondant de l'erreur de courant à stderr Original: displays a character string corresponding of the current error to stderr The text has been machine-translated via Google Translate. (fonction) [edit] | |
chèques pour une erreur de fichier Original: checks for a file error The text has been machine-translated via Google Translate. (fonction) [edit] | |
C documentation for feof | |