Easiest way would be to use the snprintf function. It basically prints to a buffer in memory instead of the screen.
int snprintf ( char *str, size_t n,
const char *format, ... );
(The string would have to be of type char*, not const char*, and I'm assuming var1 and var2 are...