uvszprintf(3alleg4)
β¨ uvszprintf β¨
okay bestie, this one lives in the Allegro manual, section 3alleg4 β it's uvszprintf, and it's giving "I write your formatted text into a buffer but I need you to hand me the va_list yourself" energy. π
πΈ SYNOPSIS πΈ
#include <allegro.h>
int uvszprintf(char *buf, int size, const char *format, va_list args);
π DESCRIPTION π
So this is literally like uszprintf(), except instead of passing the variable arguments themselves, you pass the variable argument list directly. same vibes, different delivery method. π
Here's the whole thing in action, no cap:
#include <stdarg.h>
void log_message(const char *format, ...)
{
char buffer[100];
va_list parameters;
va_start(parameters, format);
uvszprintf(buffer, sizeof(buffer), format, parameters);
va_end(parameters);
append_buffer_to_logfile(log_name, buffer);
send_buffer_to_other_networked_players(multicast_ip, buffer);
and_also_print_it_on_the_screen(cool_font, buffer);
}
void some_other_function(void)
{
log_message("Hello %s, are you %d years old?\n", "Dave", 25);
}
see how log_message takes the ... and then forwards parameters straight into uvszprintf? that's the whole point, bestie. the wrapper function stays a wrapper function. π
π RETURN VALUE π
It returns the number of characters that would have been written if nothing got truncated β exactly like uvsprintf does β and nope, that count does not include the terminating null character. π¦
heads up: "would have been written" is doing a lot of work in that sentence. truncation doesn't change the return value, so don't go using it as "how many chars actually landed in my buffer". π
β SEE ALSO β
mwah π that's the whole page. this lil icon shipped with Allegro, version 4.4.3 β so go forth, pass your va_list around responsibly, and slay. periodt. π«Άβ¨
π¦ 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