dcsimg
November 29, 2020
Hot Topics:

A Simple CString Tokenizer

  • By Richard Case
  • Send Email »
  • More Articles »

As the name suggests, this is a simple class to extract tokens from a CSting. I wrote this class becuase during the course of my final year project at University I needed a simple way to extract 'tokens' from a CString. This is what I came up with. Its probably not the best or most effeicent way to accomplish the task - but it works which in the main thing.

To use the CToken class:

-First include the CToken header file in your porgram:

#include "Token.h"

-Then you are free to create and use an instance of CToken. For example:

CString str = "A B C D"
CString newTok;
CToken tok(str);
tok.SetToken(" ");
while(tok.MoreTokens())
{
   newTok = tok.GetToken()
}
Improvements:
If people can suggest any improvements or there bugs please drop me an email

Download demo project - 15 KB

Download source - 3 KB

Date Posted: March 3, 1999






This article was originally published on March 3, 1999

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.


Thanks for your registration, follow us on our social networks to keep up-to-date