Thread: Proble tokenizing string

  1. #1
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283

    Proble tokenizing string

    Something is wrong in this function. I could have a string that ends with a '?' but it's still included for some reason. For example, "How are you?" It returns 'How', 'are', 'you?' Why does it include the question mark? Thanks.

    Code:
    vector<String> Split(bool uppercase = false, const char *delims =", .;:'!?@#$%^&*()_+-[]\\|");
    Code:
    vector<String> String::Split(bool uppercase, const char *delims)
    {
    	vector<String> vColl;
    	char *p_tok;
    	char *p = m_p;
    
    	p_tok = strtok(p, delims);
    
    	while (p_tok != NULL)
    	{
    		if (uppercase) {
    			*p_tok = toupper(*p_tok);
    		} else {
    			*p_tok = tolower(*p_tok);
    		}
    
    		vColl.push_back(p_tok);
    		p_tok = strtok(NULL, delims);  
    	}
    
    	return vColl;
    }

  2. #2
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    As strange as it sounds, it's working fine now without any modification. No clue.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM