Is there a way to use the C sprintf() function without it adding a \'\\0\' character at the end of its output? I need to write formatted text in the middle of a fixed width stri
sprintf returns the length of the string written (not including the null terminal), you could use that to know where the null terminal was, and change the null terminal character to something else (ie a space). That would be more efficient than using strncpy.
unsigned int len = sprintf(str, ...);
str[len] = '';