Text with variables

How can I put variables in the text with the script editor?
strcpy(destination, "Input text here\n");
int var = 10;
strcpy(text, "My variable: ");
strcat(text, var);
sprintf(text, "Game File 1: %d%%\nGame File 2: %d%%", var1, var2);