converting numerical values to irrlicht strings
converting numerical values to irrlicht strings
How can i convert any numerical value to an irrlicht useable string and maybe concatenate it to another string?
ru guo ni yao ai, ni jiang bu hui shi qu
-
- Posts: 118
- Joined: Thu Sep 18, 2003 10:05 pm
- Location: switzerland
-
- Posts: 118
- Joined: Thu Sep 18, 2003 10:05 pm
- Location: switzerland
not that i know.
where you must take care is that you can only concatenate wchar strings with wchar strings and char strings with char strings. otherwise you'll get alot of strange symbols printed out.
this should work:
wchar_t myWString=L"Hi";
float myFloat=6.23f;
wchar_t buf[255];
swprintf(buf,"%f", myFloat); // buf == L"6.23"
swprintf(buf,"%f %s",myFloat,myWString);// buf == L"6.23 Hi"
swprintf(buf,"%f %s",3.14,L"Hello"); // buf == L"3.14 Hello"
cheers
tom
where you must take care is that you can only concatenate wchar strings with wchar strings and char strings with char strings. otherwise you'll get alot of strange symbols printed out.
this should work:
wchar_t myWString=L"Hi";
float myFloat=6.23f;
wchar_t buf[255];
swprintf(buf,"%f", myFloat); // buf == L"6.23"
swprintf(buf,"%f %s",myFloat,myWString);// buf == L"6.23 Hi"
swprintf(buf,"%f %s",3.14,L"Hello"); // buf == L"3.14 Hello"
cheers
tom
Well, doesnt works. After some trial and error and man, got this:Gorgon Zola wrote:not that i know.
where you must take care is that you can only concatenate wchar strings with wchar strings and char strings with char strings. otherwise you'll get alot of strange symbols printed out.
this should work:
wchar_t myWString=L"Hi";
float myFloat=6.23f;
wchar_t buf[255];
swprintf(buf,"%f", myFloat); // buf == L"6.23"
swprintf(buf,"%f %s",myFloat,myWString);// buf == L"6.23 Hi"
swprintf(buf,"%f %s",3.14,L"Hello"); // buf == L"3.14 Hello"
wchar_t buf[255];
swprintf(buf, 30,L"%s %i", L"Strength ",20); // Strength
statsn->setText(buf);
But this only displays "S 20" instead of "Strength 20"
ru guo ni yao ai, ni jiang bu hui shi qu
-
- Posts: 118
- Joined: Thu Sep 18, 2003 10:05 pm
- Location: switzerland
Most of them are not statndard C / C++ functions and might not be included in all implamentations. And AFAIR they are only wrappers for sprintf() or similar function.R00mpel wrote:To convert numerical values into strings, you can also use _itoa, _itow, _ecvt, _fcvt and some other functions. See documentation for further information...
Tomasz Nowakowski
Openoko - www.openoko.pl
Openoko - www.openoko.pl
you might want to have a look at boost. http://www.boost.org there are some lexical cast libraries.
Please send me an e-mail instead of a private message.