Equivilant of JScript's "split" in C++
-
Hi, I’ve been trying for most of the day now to write a function that is basically the same as JScript's split function (you pass a string containing one or more key letters, and the key letter, and the function returns an array [or list] of the strings). e.g. (pseudo code).
CStringList Foo::Split(CString strBigString, CString srtKeyletter)
{
.. do stuff here that creates an array of keyletter delimited stringsreturn [CStringList containing the strings]
}However, I can’t get it to work. Not even slightly! Could anyone here help? Yours, Peter
-
Hi, I’ve been trying for most of the day now to write a function that is basically the same as JScript's split function (you pass a string containing one or more key letters, and the key letter, and the function returns an array [or list] of the strings). e.g. (pseudo code).
CStringList Foo::Split(CString strBigString, CString srtKeyletter)
{
.. do stuff here that creates an array of keyletter delimited stringsreturn [CStringList containing the strings]
}However, I can’t get it to work. Not even slightly! Could anyone here help? Yours, Peter
Hi Peter, are you after a strtok or wstrtok type function. Its a c library call that tokenizes as you describe http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/\_crt\_strtok.2c\_.wcstok.2c\_.\_mbstok.asp or use the CString FindOneOf to implement what you want John
-
Hi Peter, are you after a strtok or wstrtok type function. Its a c library call that tokenizes as you describe http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/\_crt\_strtok.2c\_.wcstok.2c\_.\_mbstok.asp or use the CString FindOneOf to implement what you want John