dcsimg

A Simple CString Tokenizer

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



This article was originally published on March 3rd, 1999

Most Popular Programming Stories

More for Developers

RSS Feeds

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