Something I am having a problem with

Started by
4 comments, last by leggyguy 22 years, 2 months ago
hi, I am trying to do this, and it won't let me. char buf [40]; char *state "Alabama"; double temp = 25.72; wsprintf (buf, "The %s temperature is %f ", state, temp); TextOut (hDC, 200, 200, buf, strlen (buf) ); Now this is prining out this: "The Alabama temperature is f" Anyone able to tell me why it won't just print my double? Thanks. Edited by - Leggyguy on February 6, 2002 6:43:01 PM
Advertisement
Could you post your actual code, as that snippet on its own wouldn''t compile. You are initialising a float called ''x'' but you are passing an undeclared float called ''temp'' to the wsprintf call.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
Sorry, you are right.

x should have been temp. I will change it now on the initial post.

But otherwise, that is the code, apart from the obvious (setting up the hdc, etc).
wsprintf just DOES NOT work with floats (i have no clue why) , use sprintf, that will work with floats and doubles...
Just a curious question; why do you use wsprintf with a non-wide character string?


Message from above:
Damn, my hair is grey!
Message from above:Damn, my hair is grey!
Thanks AP. That is the problem, wsprintf just can''t handle doubles. sprintf works fine, just as you suggested. Wierd.

Gamekeeper, I do actually use a lot of wide-character functionality. First, the program I am working on - a business/currency calculator - I am hoping to translate into Japanese. using wideboys will help me do that with a little less effort when the time comes. Second, why not use wideboys? Any efficeincy issues are so negligable as to be non-existent.

This topic is closed to new replies.

Advertisement