c++ - Why the thrid parameter of the wcstok_s function is a dimensional pointer? -


the wcstok_s function how achieve?

the wcstok function has 2 parameters , how save string when call in second time , first parameter 'null'.

these 2 how return pointer , function finished , why temporary memory reserved , return *wchar string ending '\0';

this incorrect code:

tchar *mywtok(tchar *tsztext, int x, tchar *tnext) {     tchar res[1005];     if (tsztext == nullptr)         tsztext = tnext;     int len = wcslen(tsztext);     int rlen = 0;     for(int = 0; < len; i++){         if (tsztext[i] != x) {             res[rlen++] = tsztext[i];         }         else {             res[rlen] = '\0';             tnext = tsztext + i;             return res;         }     }     res[rlen] = '\0';     tnext = nullptr;     return res; } 

the wcstok_s ignore "",such ",,a," return "a",if want return "" "a" or "","","a".

which pointer tnext points should modified @ end of function hold pointer @ character following end of last token matched, can loop on matches in exemple :

https://msdn.microsoft.com/en-us/library/ftsafwz3.aspx

so, answer question, pointer pointer because function needs modify pointer pointer allow loops.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -