Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   tokenize method (http://www.go4expert.com/forums/tokenize-method-t15913/)

e4321 23Jan2009 18:45

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.
Code:


#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();
 
};


xpi0t0s 23Jan2009 20:55

Re: tokenize method
 
"I am not sure if the characters are stored correctly in the array"

What a strange way of putting it. Are they stored correctly or aren't they? If you display the array on screen does it appear as you expect?

Again this is a class on its own with no main function. Are you posting homework assignments in the hope that we'll do them for you?


All times are GMT +5.5. The time now is 23:42.