I've been learning C++ for the past few days, and I'm trying to write my own string and StringTokenizer class in order to better understand chars and char arrays (that is why I am not using the predefined string class).
I can't seem to return this character array from this part of my StringTokenizer class ... can someone help me? Maybe I just don't know the syntax...
Code:
char StringTokenizerC::nextToken()
{
m_position++;
int j = 0;
int p = 0;
int start = 0;
char* token = new char[MAXLINE];
RVString rvs(m_string);
int begin = 0;
for(int i = 0; i < m_position; i++) {
start = rvs.find_first_of(m_string, "\0", begin);
begin = start + 1;
}
int end = rvs.find_first_of(m_string, "\0", begin + 1);
for(j = start, p = 0; p < (end - start); j++, p++) {
token[p] = m_string[j]; //Adds the characters to the string from the start and end points
}
return token;
}