al_fread16le(3alleg5)

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

al_fread16le πŸ’–

okay bestie, welcome to the Allegro 5 API β€” specifically the al_fread16le page, and yes it's giving "tiny function, big feelings" energy. ✨


✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

int16_t al_fread16le(ALLEGRO_FILE *f)

look at her. one function, one file pointer, one little int16_t returning. iconic behavior honestly. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so what does she do?? she reads a 16-bit word out of the file in little-endian format β€” that means LSB first (least significant byte walks in first, like she owns the place). πŸšΆβ™€οΈπŸ’¨

On success? you get the 16-bit word back. slay. 🫢

On failure? you get EOF (-1). 😭

okay but here's the tea, and it's important tea: -1 is also a valid return value. so like... you literally cannot tell "it broke" from "the data was -1" just by looking at the return. do NOT come for me, I'm just the messenger. πŸ™ˆ

so instead, bestie, you gotta do the extra detective work:

periodt. no cap.


🌸 SEE ALSO 🌸

  • al_fread16be(3alleg5) β€” the big-endian sibling, for when the bytes get read in the other order πŸ¦‹

and that's the whole page, bestie!! this was pulled straight from the Allegro reference manual for Allegro 5 (al_fread16le(3alleg5)), so go forth, read your little-endian words, and check al_feof and al_ferror like the responsible main character you are. mwah. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from