uvszprintf(3)

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

✨ NAME ✨

uvszprintf β€” bestie, this one writes formatted data into a buffer, using size and variable arguments πŸ’– it's part of the Allegro game programming library, periodt.


🌸 SYNOPSIS 🌸

#include <allegro.h>

int uvszprintf(char *buf, int size, const char *format, va_list args);

πŸ’… DESCRIPTION πŸ’…

okay so listen. This is literally just like uszprintf(), except instead of handing over the arguments themselves, you pass the variable argument list directly. va_list girlies, this one's for you 🫢

here's the moment, an example, 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 va_start, uvszprintf, va_end is giving main character energy? iconic honestly πŸ’–


πŸ”₯ RETURN VALUE πŸ”₯

It returns the number of characters that would have been written without eventual truncation (like with uvsprintf), not including the terminating null character. So it's telling you the size it wanted, even if it couldn't fully deliver. the way that it just... keeps receipts 😭


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole vibe, bestie πŸ¦‹ this was uvszprintf(3) from the Allegro manual, and it's brought to you by Allegro version 4.4.3 β€” go format something cute, ily, bye βœ¨πŸŽ€

πŸ“¦ where this page comes from