- Code: Select all
sprintf(text, "some text"); // this would set the actor's text to 'some text'
sprintf(text, "var = %d", var); // displays what var is equal to
If you want to display different variable types you need to use different characters. %d and %i mean integers, %lf for doubles, %s is for strings, %c is for a character, and %p for a pointer. There are a few more but those are the basics. You pass all of the variables you want into the string after the format (in the order the % comes in).
- Code: Select all
sprintf(text, "integer: %d\nstring: %s\ncharacter: %c", int_var, string_var, char_var);