al_fgets(3alleg5)

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

πŸ’– al_fgets πŸ’–

okay bestie, so this is the Allegro 5 API page for al_fgets β€” she's a little file-reading icon in the 3alleg5 manual and she's here to hand you one whole line, no cap 🫢


✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

char *al_fgets(ALLEGRO_FILE *f, char * const buf, size_t max)

🌸 DESCRIPTION 🌸

So basically? You give her a buffer, and she reads a string of bytes into it, stopping when she hits a newline or end-of-file. That's the whole vibe πŸ’…

And listen β€” the line terminator(s), if there even are any, are included in the returned string. She does not strip them, she does not play games, they come along for the ride fr fr.

Here's the tea on how much she reads: a maximum of max-1 bytes get read, and that one leftover byte is reserved for the NUL terminator. So she's always saving room to close the string off properly. Thoughtful queen behavior honestly πŸ˜­πŸ‘‘

Parameters, let's go:

  • f β€” the file you're reading from πŸ“
  • buf β€” the buffer you're filling up
  • max β€” the maximum size of the buffer

What she gives back πŸŽ€

Returns the pointer to buf on success. Returns NULL if an error happened, or if the end of file was reached without reading any bytes. So like β€” if she read nothing at all, it's a NULL situation, periodt.

Heads up bestie: go check al_fopen(3alleg5) if you wanna know about translations of end-of-line characters, because that's where that whole story lives ✨

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the page!! πŸ’œ this was the Allegro reference manual, al_fgets(3alleg5), mwah β€” go read some lines, you got this πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from