From: Dave Cullen on
Is there a more elegant way of parsing a delimited string in C++ other than
strtok? The equivalent to VB's String.Split would be nice.

The string being parsed is read from a file, and semicolon delimited.
Variable length (field count). Strtok seems crude, tho it certainly works.
I'm just wondering if there's an alternative to making 50 calls to a
function.

VC6 (MFC) but not .NET

Thanks

Dave


From: Giovanni Dicanio on

"Dave Cullen" <nospam(a)mail.com> ha scritto nel messaggio
news:uIUlATbkIHA.4076(a)TK2MSFTNGP05.phx.gbl...
> Is there a more elegant way of parsing a delimited string in C++ other
> than strtok?

You may consider the code I recently posted on microsoft.public.vc.mfc
newsgroup, in the thread "My own fuction: Access Violation error...":

http://groups.google.com/group/microsoft.public.vc.mfc/browse_thread/thread/749dc23e81858c79/e5357914058c1685?lnk=raot&fwc=1

HTH,
Giovanni


From: Giovanni Dicanio on

"Dave Cullen" <nospam(a)mail.com> ha scritto nel messaggio
news:uIUlATbkIHA.4076(a)TK2MSFTNGP05.phx.gbl...

> VC6 (MFC)

BTW: my code (referenced in above post) uses STL, and there are some
problems with STL implementation in VC6. So, if you are using VC6, I would
suggest to install the latest service pack (SP6) and apply Dinkumware
patches, or use STLport (a freely available open-source implementation of
STL).

Giovanni


From: Alex Blekhman on
"Dave Cullen" wrote:
> Is there a more elegant way of parsing a delimited string in C++
> other than strtok? The equivalent to VB's String.Split would be
> nice.
>
> The string being parsed is read from a file, and semicolon
> delimited. Variable length (field count). Strtok seems crude,
> tho it certainly works. I'm just wondering if there's an
> alternative to making 50 calls to a function.

What do you mean by "crude"? You can write a wrapper around
`strtok' that will call it internally and return an array of
tokens. Also, there is MFC's `CString::Tokenize' method.

Alex


From: Pär Buschka on
I suggest you take a look at boost, http://www.boost.org/

There you find several alternatives to strtok, such as split
http://www.boost.org/doc/libs/1_35_0/doc/html/string_algo/usage.html#id1290839
or tokenizer http://www.boost.org/doc/libs/1_35_0/libs/tokenizer/index.html

/P�r

"Dave Cullen" <nospam(a)mail.com> skrev i meddelandet
news:uIUlATbkIHA.4076(a)TK2MSFTNGP05.phx.gbl...
> Is there a more elegant way of parsing a delimited string in C++ other
> than strtok? The equivalent to VB's String.Split would be nice.
>
> The string being parsed is read from a file, and semicolon delimited.
> Variable length (field count). Strtok seems crude, tho it certainly works.
> I'm just wondering if there's an alternative to making 50 calls to a
> function.
>
> VC6 (MFC) but not .NET
>
> Thanks
>
> Dave
>
>

 |  Next  |  Last
Pages: 1 2
Prev: precompiled header file
Next: _tmain & _TCHAR*