Tokenizing a string We will discuss how a string can be tokenized using the C standard library function strtok. A demonstration program is available as testToken.cpp
Sample code #include #include using std::cout; using std::endl; int main(void) { char strIn[] = "This is my test string, isn't it?"; char delim[] = " ,\'\"\t-?!$%&*()_:;./\\"; char* p = strtok(strIn, delim); while (p != NULL) { cout << p << endl; p = strtok(NULL, delim); } return 0; }