#7 TokenCount()

closed
nobody
None
5
2009-11-13
2009-09-23
Efreak
No

CString.TokenCount() function in ZNCString.cpp, to give the total number of tokens in the string.

Discussion

  • Why do you need the total number of tokens?

    I think what you are doing should be done with CString::Split().

    psychon

    VCString tokens;
    VCString::iterator it;
    CString str = "Hello there how are you?";
    str.split(" ", tokens, false); // false -> skips empty tokens
    cout << "there are " << tokens.size() << " tokens\n";
    for (it = tokens.begin(); it != tokens.end(); it)
    cout << "Next token: " << *it << "\n";
    cout.flush();

     
  • Because I didn't know I could do that; ty

     
  • Psychon
    Psychon
    2009-11-13

    • status: open --> closed