Is there a standard C function that allows you to build strings using format specifiers?
Right now I’m doing this:
char buffer[256];
char *name = "Fred";
strcpy(buffer, "Hello, ");
strcat(buffer, name);
strcat(buffer, ". How are you today?\n");
Is there a way to add the message to buffer in one function?
Something like this:
makestr(buffer, "Hello, %s. How are you today?\n", name);
sprintf
Be careful when using it because sprintf is not a safe function and can suffer from buffer overflows.