Are you sure? The strtok_s() I found at MSDN does not have a size parameter; it is declared exactly like POSIX.1-2001 strtok_r() is.
Are you sure? The strtok_s() I found at MSDN does not have a size parameter; it is declared exactly like POSIX.1-2001 strtok_r() is.
Yes, the standardised version of strtok_s does have a second parameter for size. So maybe the Microsoft advocates were not entirely able to get their way.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Oh, you were talking about the standard C11 strtok_s(), and not the strtok_s() Microsoft has implemented and calls standard. You should have mentioned it the first time you referred to it; I assumed you were still referring to the Microsoft strtok_s() mentioned earlier.
Okay, I think we're in agreement that POSIX.1-2001 strtok_r() and Microsoft strtok_s() (Visual Studio 2005 to 2013) have the exact same interface.
The strtok_s() function, as defined by the C11 standard, has an additional size parameter. The support for this (and other similar functions) is optional, indicated by __STD_LIB_EXT1__, and the function is only declared if __STDC_WANT_LIB_EXT1__ is defined prior to including string.h .
Which, in my opinion, makes it an even more reason to use the preprocessor compatibility magic I showed much earlier, and strtok_r().