1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

tokenize method

Discussion in 'C' started by e4321, Jan 23, 2009.

  1. e4321

    e4321 New Member

    Joined:
    Jan 13, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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();
     
    };
     
    Last edited by a moderator: Jan 23, 2009
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    "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?
     

Share This Page