Monday, March 14, 2011

String Tokenizer in C++

Hi guys,
I'm sure that many of you might have tried to Tokenize a String in cpp. There is built in support in cpp among the hassles of handling strings in C/C++. Its included in "string.h".


We use the char* strtok(char* string2btokenized, char* wildcardchars2bremoved) function which takes 2 parameters.

First one being the string to be tokenized and second being characters to be removed.

In this program I have passed those as the first 2 parameters to the main function and hence stored in argv[1] and argv[2]. Code is self explanatory.


No comments:

Post a Comment