Help me about converting char wchar_t ....

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
darko024
Posts: 9
Joined: Tue Mar 14, 2006 2:45 am

Help me about converting char wchar_t ....

Post by darko024 »

hi ,

i have one variable ( int score ). I need help to show this value into staticText.

I was try something like this

Code: Select all

            
            char score_buff[10]
            wchar_t score_str[10];
            score_text = guienv->addStaticText(L"300", rect<s32>(180,310,230,340), false);

            sprintf(score_buff,"%d",score1); // convert form int to char
	   
            sprintf(score_str, 10 , L"%s", score_buff); // convert char to wchar_t
           
            score_text->setText(score1_str); 
  


But nothing want to work ...

I will really be happy if somebody explain me how to do this ?

Thanx
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

staticText = gui->addStaticText(L"", irr::core::rect<irr::s32>(10, 10, 110, 22));
irr::core::stringw sw(???);//<--you can put here char. int, wchar_t...

//and then
staticText->setText(sw.c_str());

//maybe before that
staticText->setOverideColor(someColor);
staticText->setOverideFont(someFont);

And if you need later you can convert char, wchar_t to int, float
with this functions atoi, atof, _wtoi, _wtof.

btw. where are you from?
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

like he said have a look at string.h in the core section of irrlicht.
Post Reply