Skip to main content
GameDev.net gamedev.net
๐Ÿ”’ Locked

printing variables

Started by XanderLing Dec 2, 2001 at 5:39 AM 1 replies 150+ views
Original Post
XanderLing
XanderLing
hello, i know how to print text to the screen using the tutorials from nehe.gamedev.net. however, i don''t know how to pass a variable to be printed. has anyone ever printed variables like floating point numbers? Thanks.
xyzzy00
xyzzy00
Use sprintf.. it is your friend.

char sz[32];
sprintf(sz, "%g", 42.0f);

Now you have a text string ''sz'' that you know how to draw.

xyzzy
XanderLing
XanderLing
Hehehe,

Thanks. It works.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.