equiv from python

grelbr grelbr at hotmail.com
Wed Aug 29 10:09:15 EDT 2001


strombrg at seki.acs.uci.edu (Dan Stromberg) wrote in message news:<9mh27s$dmi$1 at news.service.uci.edu>...
[snip]
> IE, can the standard c++ library take a string, split it up on a
> particular separator character, and return the corresponding list of
> strings?
> 
> I know I can write something to do this, but I'd rather learn how to
> use the STL or similar, if applicable.

Well, there's strtok(). But, I personally think the best use of that
function is as a teacher of the unwary. Before you elect to use that
function, make sure you read the *entire* description in your docs,
all the way to the end and every word. Be sure to pay attention to
the fact that there is a static storage space involved, and be sure
you know what that implies.

Maybe I sound pretty grumpy on this point. But that's because, some
years ago, I blindly used strtok() without paying attention to that
stuff. Don't you be like I was. Get smart sooner rather than later.
grelbr



More information about the Python-list mailing list