Custom String Parsing Function
Hi, I want to make a function Called Gettok(). The idea for this function comes from the mIRC scripting language's function called $gettok. It works like this:
gettok(text,N,C)
Returns the Nth 'token' in text.
Example:
gettok(this is a string,1,32) returns "this"
gettok(this is a string,2,32) returns "is"
gettok(this is a string,3,32) returns "a"
gettok(this is a string,4,32) returns "string"
gettok(this is a string,5,32) returns NULL (or "NULL")
The string "this is a string" is seperated by Character Code 32, which is a space.
If i wanted too, I could specify a different character code, For example 115, which is the ASCII code for the letter S. And then do this:
gettok(this is a string,1,115) returns "thi"
gettok(this is a string,2,115) returns "i"
gettok(this is a string,3,115) returns "a "
gettok(this is a string,4,115) returns "tring"
gettok(this is a string,5,115) returns NULL (or "NULL")
I would want to use this Function like this:
String string1 = gettok(Edit1->Text,3,32)
or
Char *string[]=gettok(Edit1->Text,2,42)
Any tips how to make such a function?