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.
spike314
Posts: 27 Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:
Post
by spike314 » Sat Jan 26, 2008 12:18 am
Hi all
can someone please tell me whats wrong wiv this code all I'm trying to do is find an object named "tree" from my structure list but nothing is showing up but as i have set o.Name="tree" i know there is 1 object with that name.
Code: Select all
struct Obj
{
const char*Name;
};
list<struct Obj> obj;
struct Obj o;
o.Name="house"
obj.insert(++obj.begin(),o);
struct Obj o;
o.Name="house"
obj.insert(++obj.begin(),o);
struct Obj o;
o.Name="tree"
obj.insert(++obj.begin(),o);
//SOMEWHERE ELSE IN MY CODE
void ListObjects()
{
core::stringw str1 = L"";
list<struct Obj>::iterator o; //also tryed it without struct
for(o=obj.begin(); o != obj.end(); ++o)
{
if (o->Name=="tree")
{
str1+=" ";
str1+="A tree";
mydevice->setWindowCaption(str1.c_str());
}
}
}
Thanks for any help.
Last edited by
spike314 on Sat Jan 26, 2008 1:33 am, edited 1 time in total.
You can have all the power in the world but if you have no one to follow you what good is the power?
Acki
Posts: 3496 Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:
Post
by Acki » Sat Jan 26, 2008 12:32 am
try to use also stringw with the struct !!!
you can't add any text to a char* like you did (strcpy(...) would be used there)...
Code: Select all
struct Obj
{
core::stringw Name;
};
spike314
Posts: 27 Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:
Post
by spike314 » Sat Jan 26, 2008 12:37 am
no didnt still dont work
I dont get it ive tryed tests and they all work but this just dont.
You can have all the power in the world but if you have no one to follow you what good is the power?
spike314
Posts: 27 Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:
Post
by spike314 » Sat Jan 26, 2008 1:34 am
thanks Acki you idea did work i just needed to play around with my code abit.
You can have all the power in the world but if you have no one to follow you what good is the power?