CPB Mailing List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: copy of AnsiString
Nick,
You were correct on what was being returned from strtok(). It has been a
while since I had used it - strtok is one of the most weird functions in
ANSI C. I have provided, in the code below, the correct way to parse
aString using strtok().
I would be interested in how you are using the STL to accomplish this.
Von R. Colborn
Cornerstone Systems, Inc.
AnsiString aString = "Hello-There";
char *cp1 = 0,
*cp2 = 0,
*holdcp;
holdcp = new char[aString.Length()];
strcpy (holdcp, aString.c_str() );
cp1 = strtok (aString.c_str(), "-");
//cp1 now points to 'Hello'
cp2 = strtok (NULL, "\0");
//cp2 now points to 'There'
Memo1->Clear();
Memo1->Lines->Add(holdcp);
Memo1->Lines->Add(cp1);
Memo1->Lines->Add(cp2);
//restore the string
aString = holdcp;
W Komornicki's Home Page |
Main Index |
Thread Index