Trying to use a variable with additem

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
Clone256
Posts: 11
Joined: Thu Oct 13, 2005 9:20 pm

Trying to use a variable with additem

Post by Clone256 »

Hey. This is the first post i've made here, although I take a look around sometimes.

I'm having trouble with using a char variable with addItem().

The code is the part from the mesh viewer tutorial where it loads the model, except I added a line near the end to add an item to a listbox.

lbox->addItem(filename);

That's what I tried at first, but got an error about invalid conversion, so I tried several things that didn't work either.

Edit- I got this working last night, just was tired and forgot at first.

My problem is I want it to print the file name and not the full path.

What would be the best way to do this?
-Clone
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

most Irrlicht functions that expect a string either expect a wchar_t* or char* (look those up if you don't know what that means, google is your friend). This means that if you have a stringw, and the function expects a c8 * (which is the same as char* in Irrlicht) that you need to use stringw.c_str() in order to translate it. So what you want is:

lbox->addItem(filename.c_str());
Clone256
Posts: 11
Joined: Thu Oct 13, 2005 9:20 pm

Post by Clone256 »

Well, I knew about that stuff above, but not the last part. When I try to use that line I get an error though: request for member `c_str' in `filename', which is of non-aggregate type `c8[1024]'

-Clone
Post Reply