pack_fgets(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– pack_fgets(3) β€” the Allegro manual, but make it cute πŸ’–

okay bestie, welcome to the Allegro manual, section 3 (that's the library functions girlies ✨). today's main character is pack_fgets, and she's here to read you a whole entire line. periodt.


✨ NAME ✨

pack_fgets β€” reads a line from the stream. it's giving Allegro game programming library energy πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

char *pack_fgets(char *p, int max, PACKFILE *f);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this function reads a line from the stream f, and stores it at the location pointed to by p. iconic behavior, no cap.

it stops when it hits a linefeed, or when max bytes have been read β€” whichever comes first, and honestly same.

the end of line is handled by detecting the right combination of characters for the platform. she's multilingual, she's cultured πŸ’…. she supports:

  • CR-LF (DOS/Windows)
  • LF (Unix)
  • CR (Mac)

formats. however!! the trailing carriage return is not included in the returned string, and that's on purpose β€” it's so your code stays easy to port across platforms. it's giving cross-platform queen. if you actually need that carriage return, use pack_fread() and/or pack_getc() instead. iykyk.

πŸ“ Note: this function internally may make calls to pack_ungetc, so you cannot use pack_ungetc directly afterwards. like, she already used it, bestie. it's taken. πŸ™ˆ

Example:

char buf[256];
...
while (pack_fgets(buf, sizeof(buf), input_file)) {
   /* Process input line. */
}
fclose(input_file);

look at her looping like that 😭 ate and left no crumbs.


🌈 RETURN VALUE 🌈

returns the pointer p on success πŸ’–, or NULL on error πŸ’€.


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, bestie! this lil' section of the Allegro manual is from version 4.4.3, and you've been reading pack_fgets(3) 🫢 go read a line, slay, and remember: no trailing carriage returns in this house. bye bestie!! πŸ‘‘βœ¨πŸŒΈ

πŸ“¦ where this page comes from