e.g..Code:string GetTok(string token,int nthToken,int ascSep) { int count = 1, start = 0, pos = 0; while (count <= nthToken) { pos = (token.find((char)ascSep,start) - start); if (count == nthToken) { return token.substr(start,pos); break; } start = (start + pos) + 1; count++; } return ""; }
GetTok(hi there guys, 1, 32) = hi
GetTok(hi there guys, 3, 32) = guys
etc, where the 3rd parameter is the ascii value to seperate the first string
any ideas if this can be coded better guys?




Reply With Quote