What is the equivalent of strtok_s in VC7?

The strtok_s function exists in vc8, but not in vc7. So what's the function (or code) that does the equivalent of strtok_s in vc7?

0


source to share


1 answer


Take a look at this MSDN page .

As far as I can tell, security enhancements a) Make strtok () reentrant (and thread safe) if the "context" parameter is needed, and b) make it safe for use with NULL pointers. (The actual behavior in case of NULL parameters is specified in the table on the page I linked.)



As for the VC7 alternative, you'll have to write (or import) it yourself. NULL safety is easy to do externally, you just need to be careful not to skip NULL rows where nobody is expected; but as reentrancy goes, there is no way for strtok () to handle this.

Take a look at this and this question. I believe POSIX also provides a reentrant version of strtok () called strtok_r (); you can search for it. It would also be a good (and short) exercise to write the implementation yourself. Should not take more than 10 lines of code.

+3


source







All Articles