pack_fgets(3alleg4)
β¨ NAME β¨
okay so bestie, this page is all about pack_fgets(3alleg4) from the Allegro manual β it's the one that reads a line from the stream. Allegro game programming library, periodt. π
π¦ SYNOPSIS π¦
#include <allegro.h>
char *pack_fgets(char *p, int max, PACKFILE *f);
π DESCRIPTION π
So here's the vibe: pack_fgets reads a line from the stream f, and it stores that line at the location pointed to by p. It stops when a linefeed is encountered, or when max bytes have been read. Simple as that, no cap. β¨
The end of line is handled by detecting the right combination of characters for the platform. It supports CR-LF (DOS/Windows), LF (Unix), and CR (Mac) formats. But β and this is the important part β the trailing carriage return is not included in the returned string, so your code stays easily portable across platforms. If you actually need that carriage return, you gotta use pack_fread() and/or pack_getc() instead. π«Ά
Note: this function internally may make calls topack_ungetc, so you cannot usepack_ungetcdirectly afterwards. Not me warning you twice, but likeβ¦ be aware. π
Example, because we love a little demo:
char buf[256];
...
while (pack_fgets(buf, sizeof(buf), input_file)) {
/* Process input line. */
}
fclose(input_file);
π RETURN VALUE π
It returns the pointer p on success, or NULL on error. That's it, that's the whole mood. π
π SEE ALSO π
pack_fopen(3alleg4)pack_fopen_chunk(3alleg4)pack_fread(3alleg4)pack_getc(3alleg4)pack_ungetc(3alleg4)
Allegro version 4.4.3, bestie β that's the source and version for this lil manual page. Go read some lines, slay, and don't forget your carriage returns unless you're using pack_fread() or pack_getc(). mwah ππΈ
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms