okay, sorry for the long time to reply, i pulled off an all-nighter and dozed off.
first reply:
Hmm... Right, guess i shouldn''t pass the variable. I don''t know where that came from, i guess i need more experience with pass by reference...
you may be right, bastardos. However, i simplified that for my posting (and my attempts at fixing it). Both of the following lines produce the same gibberish:
sprintf(Text, "Credits: %u\n%s", App->m_Player.GetCredits(), App->m_Total.GetNowString(tempText).c_str());
sprintf(Text, App->m_Total.GetNowString(tempText).c_str());
Perhaps my mistake (if it was wrong) was to assume that sprintf just copied the second arguement into the first arguement (after replacing all %x''s).
Also, thanks for the link but i have it already bookmarked... yay for google
VolkerG:
Actually, they return DWORDS to be precise, but yes. So... what you''re saying is that the integers aren''t converted by the std::string class? I''d find that rather strange considering std::cout does it... I''ll test that with a sprintf later, sounds like that might be it.
Zahlman:
the cFont class is basically a wrapper for the following DirectX call:
INT DrawText(
LPCSTR pString,
INT Count,
LPRECT pRect,
DWORD Format,
D3DCOLOR Color
);
As you can see, DrawText takes a Long Pointer to C STRing (... i think). So, even if i modified the cFont.Print class to take a std::string variable, at some point i''d have to convert anyway.
Also, sorry for that, 536 is the x value and 7 the y value of the position to draw (top right corner on 800x600).
>>And then you don''t do anything with the return value.
I get where passing the variable to it doesn''t do anything, but i do return s, and then doesn''t this line call the c_str() of the returned std::string?
App->m_Total.GetNowString(tempText).c_str()
= s.c_str() ?
>>Oh, and FFS do the getNowString() calculations in the cTimeandDate class, and delegate there from cTotal. It''s cleaner OO and should actually be faster (because within cTimeandDate you have direct access to the m_Year etc.... even if you made them public, they''re more directly accessible in cTimeandDate).
Thanks, will do.
Thanks, iamjoesname, but i already do...
bastardos:
true, the second variable of sprintf is usually (and meant to be) a format string, however in my console app i''ve done the following before:
sprintf(str1, "Hello!");
Since that doesn''t produce any errors, i''m assuming the following wouldn''t either:
str2 = "Hello!";
sprintf(str1, str2);
(... well, initialize str2 right and it''d work. Sorry, not much good with Cstrings.