al_feof(3alleg5)
β¨ al_feof β Allegro 5 API β¨
okay bestie, welcome to the al_feof(3alleg5) page, you're gonna eat this one up π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
bool al_feof(ALLEGRO_FILE *f)
π DESCRIPTION π
So like. al_feof returns true if the end-of-file indicator has been set on the file, i.e. we have attempted to read past the end of the file. π
NOT ME GETTING THIS WRONG FOR YEARSβ it does not return true just because you're simply at the end of the file. like, being at the end and having tried to read past the end are two completely different vibes, and this function only cares about the second one. π
the following code correctly reads two bytes, even when the file contains exactly two bytes:
int b1 = al_fgetc(f);
int b2 = al_fgetc(f);
if (al_feof(f)) {
/* At least one byte was unsuccessfully read. */
report_error();
}
so yeah, you can read exactly two bytes out of a two-byte file and not trip the EOF flag, because both reads succeeded. the flag only pops when a read actually fails. it's giving "last one to leave doesn't get flagged, only the one who tried to go past the exit" πͺβ¨
π¦ SEE ALSO π¦
and that's the whole page, no cap π«Ά Allegro reference manual, al_feof(3alleg5) β go slay your file reads, queen ππ
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms