I'm wondering if this is the proper way to concatenate and NUL terminate strings including width.
#define FOO "foo"
const char *bar = "bar";
int n = 10;
float f = 10.2;
char *s;
int l;
l = snprintf (NULL, 0, "%-6s %-10s %4d %4f",FOO, bar, n, f);
s = malloc (l + 4); // should it be the number of formats tags?
if (s == null) return 1;
sprintf (s, "%-6s %-10s %4d %4f", FOO, bar, n, f);
snprintfand thesprintf. It'd really suck if it got changed in one place and not the other!const char* fmt_str = "%-6s %-10s %4d %4f";and use that as your format string in both places.