tokenize method

This method takes two strings as input s1, a generic string, and s2 containing delimiters. s1 is verified against s2 and depending on the type of character it is stored in a two dimensional array. The problem that I have is I am not sure if the characters are stored correctly in the array, and how to arrange the delimiter characters in increasing order.

#pragma once

class Tokenizer
{
public:
Tokenizer(void);
~Tokenizer(void);
void tokenize(char *s1, char *s2){
for(int i=0; i<size of s1; i++){
for(int j=0; j<size of s2; j++){
if(s1[i]==s2[j]){
s3[i]=s1[i];
}
else{
s3[k]=s1[i];
k++;
}
break;
}
}
}

while(i<sizeof s2){
l.add(s2[i]);
}
}

private:
char * s1, * s2, * s3[][];
LinkedList * l=new LinkedList();

};

Comments

  • I don't quite understand what you want. The algorithm itself doesn't make any sense. And where are the strings allocated?

    char * s1, * s2, * s3[][];

    Why did you make two one-dimensional pointers and one three-dimensional?


    : LinkedList * l=new LinkedList();

    This isn't valid C++, all initialization must be done in the constructor.


    : while(i<sizeof s2){

    This won't work, s2 is a pointer and not a statically allocated array.
  • I was trying to separate between delimiters and string literals (sin, cos, tan) and store them in one string, but I am not sure if this is the exact requirement.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories