Skip to main content
gamedev.net
🔒 Locked

wsprintf equivalent

Started by Shmuel 11 replies 5.1k views
Original Post
Shmuel
Shmuel
I'm programming a game that uses SDL and I don't want to limit it to the windows platform by using any of the windows only functions. Teh book I'm using uses the function wsprintf, which is defined in windows.h. My question is: Is there a c or C++ function like wsprintf? I know about sprintf, but it doesn't append to the string does it? I wasn't sure about that.
case ShmuelPosted:StupidPosts++;
Sneftel
Sneftel
wsprintf is not a windows-only function, tho it is not a POSIX function. swprintf is more common on UNIX boxes. Note that the only substantial difference between wsprintf and sprintf is that wsprintf uses wide (international) characters.
Shmuel
Shmuel
What include file is it in, because including windows.h included it.
case ShmuelPosted:StupidPosts++;
Fruny
Fruny
I have swprintf in wchar.h
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Shmuel
Shmuel
fruny, do you mean wsprintf?
case ShmuelPosted:StupidPosts++;
Washu
Washu
No, he means swprintf. It is part of the CRT, which should be with all C compilers.
int sprintf( char *buffer, const char *format [, argument] ... );int swprintf( wchar_t *buffer, const wchar_t *format [, argument] ... );
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
Shmuel
Shmuel
whats the difference between the two?
case ShmuelPosted:StupidPosts++;
Shmuel
Shmuel
Where is swprintf defined?
case ShmuelPosted:StupidPosts++;
Doom3Coder
Doom3Coder
#include

main()
{
char str[256];
sprintf(str,"I have owned joo!");
}
HOW DO I MAKE GAMES?READ THIS:http://www.lupinegames.com/articles/path_to_dev.html
Shmuel
Shmuel
no, swprintf not sprintf
case ShmuelPosted:StupidPosts++;
Shannon Barber
Shannon Barber
Could use std::wfstream (should be in fstream)
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
ApochPiQ
ApochPiQ
Quote:
Original post by Shmuel
Where is swprintf defined?



The same header as sprintf, and listed in the Requirements section in this article, which I linked to above.

Topic Locked

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

Sign in to reply to this topic.