const char* strrep(listing list) { //https://stackoverflow.com/q/4836534/9295513 char* retVal = //... return retVal; } I have a struct type called listing. Is there a way to format elements as if by calling printf with ("%d %d %s...", list->elem_one, list->elem_two, list->elem_three...) but write the output to an array of char instead of to standard output?