ustrtol(3)
β¨ ustrtol(3) β¨
okay so bestie, welcome to ustrtol, straight outta the Allegro manual β aka the Allegro game programming library π. she's a lil string-to-integer converter and she's lowkey iconic for it.
πΈ NAME πΈ
ustrtol β converts a string into an integer. part of the Allegro game programming library, no cap π
π¦ SYNOPSIS π¦
#include <allegro.h>
long ustrtol(const char *s, char **endp, int base);
β¨ DESCRIPTION β¨
so what she does is: she takes the initial part of s and turns it into a signed integer, and if endp is not a NULL pointer, she sets *endp to point at the first unused character β like the first one she didn't eat π. the leftovers, basically.
the base argument is the vibe check for what base those digits (or letters, bestie, letters are digits in high bases, it's giving hex energy) should be treated as π₯.
and here's the cute part: if base is zero, she figures out the base herself by peeking at the first part of the string for a 0x, 0X, or 0 prefix, and sets the base to 16, 16, or 8 if she finds one π. if none of those prefixes show up, the default base is 10. she just knows. main character intuition fr fr.
example time, periodt:
char *endp, *string = "456.203 askdfg";
int number = ustrtol(string, &endp, 10);
π RETURN VALUE π
she returns the string converted as a value of type long int β¨.
but if nothing was converted? she returns zero and *endp points to the beginning of s β like, nothing happened, we're back where we started, awkward π.
π«Ά SEE ALSO π«Ά
and that's the whole page, bestie π. this was Allegro, version 4.4.3 β the ustrtol(3) era. slay, go convert some strings ππ
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms