use strtok() to tokenize a sentence : string token « string « C++ Tutorial






#include <iostream>
#include <cstring>

using namespace std;
int main() {
  char delims[] = "., ?;!";
  char str[] = "I like apples, pears, and grapes. Do you?";
  char *tok;
  tok = strtok(str, delims);
  while(tok) {
    cout << tok << endl;
    tok  = strtok(NULL, delims);
  }

  return 0;
}








15.25.string token
15.25.1.use strtok() to tokenize a sentence
15.25.2.use strtok() to extract keys and values stored in key/value pairs within a string