Sprintf

From Game Editor

Revision as of 20:09, 5 September 2008 by Diormeh (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

For string variables write this:

strcpy(text, (char *)YourStringVar);

or

sprintf(text, "%s", YourStringVar);

%s is for string.

For integer and real variables the same as above, %d for an integer variable and %f for real variables.

example:

sprintf(text, "A string: %s\nAn integer: %d\nA float value: %f", "Hello!", 7, 3.4);

That changes your text to:

A string: Hello!

An integer: 7

A float value: 3.4

("\n" means new line)