Adding symbols

Hey guys, i am having problems adding certain characters into a string.

The below codes basically uses boost tokenizer and seperates the string based on the delimeters which i have set.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
std::string str = "This/is/a/test'""' /v/i/a/g/r\\a/";

typedef boost::tokenizer< boost::char_separator<char> > tokenizer_type ;

const char* const dropped_delimiters = "',/!@#$%^&*()-_=+|]}[{:;'?/>.<,\\" ; // nothing

const char* const kept_delimiters = " \t" ; // space, tab

boost::char_separator<char> separator( dropped_delimiters, kept_delimiters ) ;

tokenizer_type toker( str, separator ) ;

int cnt = 0 ;

for( tokenizer_type::iterator beg = toker.begin() ; beg != toker.end(); ++beg )

std::cout << "token " << ++cnt << ": '" << *beg << "'\n";

}


The problem i am facing is i am unable to add in the symbol '"' into my dropped delimeters as when i put in the ' " ' symbol , it will seem like i closed it. Is there any way i can use to add in that particular symbol. Hope for some help here. Thank you
If I understood you correctly, an escape character (a back slash) will solve your problem.
std::string str = "\"Hello World!\", said the robot."; is a valid string.
Topic archived. No new replies allowed.