ustrtod(3alleg4)
π ustrtod β the "string goes in, float comes out" glow-up π
okay bestie, so this one lives in the Allegro game programming library manual, and it's literally just here to turn your text into a double. no cap. π¦
β¨ SYNOPSIS β¨
#include <allegro.h>
double ustrtod(const char *s, char **endp);
like, that's it. that's the whole vibe. π
πΈ DESCRIPTION πΈ
so here's the tea β β ustrtod grabs as many characters of s as look like a floating point number, mushes them into one actual floating point number, and then (if endp is not a NULL pointer) it sets *endp to point at the first character it didn't use. like it's telling you "okay girl, everything after this is all yours." π
here's the little example they gave us, and honestly it eats:
char *endp, *string = "456.203 askdfg";
double number = ustrtod(string, &endp);
see how "456.203" gets slurped up and the " askdfg" part is just left there chilling? yeah. that. β¨
π«Ά RETURN VALUE π«Ά
it hands you back the string converted as a value of type double. slay. π
but listen β if nothing got converted, it returns zero, and *endp points right back to the beginning of s. so like, it's not gonna pretend it did something it didn't. it's giving honest queen energy. π
ngl, if you're not checkingendp, you will not know the difference between a real0and a "bestie I literally couldn't read that"0. just saying. π
π SEE ALSO π
and that's the whole page, periodt. π this was ustrtod(3alleg4) from the Allegro manual, sittin' pretty at version 4.4.3. mwah, go convert something. πβπ
π¦ 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