Original Post
im working on ''tokenizing'' i guess (whatever the term is) a sentence, but im using my own function..
this coding works great right now, if i enter in for instance, "my name is bob" it will store "my", "name", "is", "bob", in 4 different elements of the array...
but is this function really what tokenizing is? is there a more efficient manner of doing it?
vector <string> strArray;
string strInput,
strTmp;
int vector_size=0;
void tokenize()
{
int mov = 0, sx = 0;
int endx = 0, arx = 0;
while(mov < vector_size) {
mov++;
if (strInput[mov] == '' '' || strInput[mov] == ''\n'' || strInput[mov] == ''\0'') {
strTmp.erase();
for (int x=sx; x<mov; x++)
{
strTmp = strTmp + strInput[x];
}
strArray[arx] = strTmp;
arx++;
sx=mov+1;
}
}
}
|