Proble tokenizing string

This is a discussion on Proble tokenizing string within the C++ Programming forums, part of the General Programming Boards category; Something is wrong in this function. I could have a string that ends with a '?' but it's still included ...

  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, 03: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, 02:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21