Problem with string::splt [solved]

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
Catprog
Posts: 164
Joined: Wed Jan 31, 2007 9:07 am
Contact:

Problem with string::splt [solved]

Post by Catprog »

i am trying to get the following code working:

Code: Select all

   void getStackFromStr(irr::core::stringc str){
 
        if(str.subString(str.size()-1,1)=="A"){
 
            str = str.subString(0,str.size()-2);
 
        }
 
        std::vector<irr::core::stringc> tiles;
 
        str.split(tiles,"A");
 
        for(int i=0;i<tiles.size();i++){
 
            printf("%s\n",tiles[i]);
 
        }
 
 
    }
The problem is my program crashes at the for loop.

Looking at my debugger it might be their is nothing in tiles at that stage.

Coming into the function str is equal to '1 0 24A1 0 24A2 0 24A'
Last edited by Catprog on Sat Aug 18, 2012 2:21 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Problem with string::splt

Post by CuteAlien »

Hm, sorry, I can't reproduce it so far - tried with svn trunk and the 1.7.3 release.

You just call it like this?

Code: Select all

 
getStackFromStr("1 0 24A1 0 24A2 0 24A");
 
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Catprog
Posts: 164
Joined: Wed Jan 31, 2007 9:07 am
Contact:

Re: Problem with string::splt

Post by Catprog »

CuteAlien wrote:Hm, sorry, I can't reproduce it so far - tried with svn trunk and the 1.7.3 release.

You just call it like this?

Code: Select all

 
getStackFromStr("1 0 24A1 0 24A2 0 24A");
 
it was called from another function which cut down a larger string into that. I tried replacing the call with your call but it still failed.

EDIT:

Found the problem.

Code: Select all

           printf("%s\n",tiles[i]);


tiles is a irrlicht string and not a c++ string.
Post Reply