Click to See Complete Forum and Search --> : Is there a function like strtok() that can use "TD" as delimiter characters?
erxuan
October 7th, 2002, 05:42 PM
I used
char *strtok(
char *strToken,
const char *strDelimit
);
in my program, and set strDelimit="TD". But I found whenever it met 'T' or 'D' it will take it as the delimiter. But I want the delimiter is "TD"(two characters together), not 'T' or 'D' alone.
Which function should I use?
cup
October 8th, 2002, 06:01 AM
Try strstr. It will tell you where the TD is. You will have to start the next search after the TD. Unlike strtok, it is thread safe and doesn't modify the string in any way.
jflegert
October 8th, 2002, 09:11 AM
Unlike strtok, it is thread safe and doesn't modify the string in any way.
Are you refering to Visual C++? According to MSDN, it is "thread safe".
from MSDN:
Note Each function uses a static variable for parsing the string into tokens. If multiple or simultaneous calls are made to the same function, a high potential for data corruption and inaccurate results exists. Therefore, do not attempt to call the same function simultaneously for different strings and be aware of calling one of these functions from within a loop where another routine may be called that uses the same function. However, calling this function simultaneously from multiple threads does not have undesirable effects.
Regards,
John Flegert
cup
October 8th, 2002, 09:21 AM
Are you refering to Visual C++? According to MSDN, it is "thread safe".
Actually, I was referring to Unix: Solaris in particular. On Solaris, strtok_r is the thread safe version. I don't know how thread safe it is on the other flavours of Unix.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.