al_fread(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_fread β€” the Allegro 5 API, bestie edition ✨

okay so this one lives in the 3alleg5 manual, and it's literally the "gimme bytes from a file" girlie. let's get into it 🫢


🌸 NAME 🌸

al_fread β€” Allegro 5 API. yes that's the whole name, she's simple and she knows it πŸ’…


✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

size_t al_fread(ALLEGRO_FILE *f, void *ptr, size_t size)

like. the signature is right there. no notes πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the vibe is: you hand her a file, a buffer, and a number, and she goes and reads size bytes into the buffer pointed to by ptr, from the given file. that's it. that's the job. main character behaviour honestly 🌈

and she returns the number of bytes she actually read. which β€” plot twist β€” is not always what you asked for 😭 because if an error happens, or the end-of-file gets reached, the return value is a short byte count (or zero). so like, you asked for 100 bytes and got 37? that's a thing that can happen. not her fault. well. kind of her fault. anyway.

⚠️ big one, bestie: al_fread() does not distinguish between EOF and other errors. she genuinely cannot tell you which one happened. she's not being mysterious, she just doesn't know πŸ’€

so if you do wanna know what went down, you gotta go ask al_feof(3alleg5) and al_ferror(3alleg5) β€” those two will tell you which of the two actually occurred. periodt.


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, they're all giving the same energy with different endianness πŸ’–


and that's the page, bestie!! this was the Allegro reference manual, and you just read al_fread(3alleg5) β€” slay, ate, no crumbs, and also please go check for EOF properly. mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from