Append formatted string to string in C without pointer arithmetic
append, c, string, string-formatting
Solution
`sprintf` returns the number of non-NUL characters written.
int len = 0;
len += sprintf(us+len, ...);
len += sprintf(us+len, ...);
...
Problem
I wrote a very simple C function to illustrate what I would like to simplify: ``` void main(int argc, char *argv[]) { char *me = "Foo"; char *you = "Bar"; char us[100]; memset(us, 100, 0x00); sprintf(us, "You: %s\n", you); sprintf(us + strlen(us), "Me: %s\n", me); sprintf(us + strlen(us), "We are %s and %s!\n", me, you); printf(us); } ``` Is there a standard library function to handle what I'm doing with `sprintf` and advancing the pointer?