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

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read