Say I have three c-style strings, char buf_1[1024], char buf_2[1024], and char buf_3[1024]. I want to tokenize them, and do things with the first token from all three, then do the same with the second token from all three, etc. Obviously, I could call strtok and loop through them from the beginning each time I want a new token. Or alternatively, pre-process all the tokens, stick them into three arrays and go from there, but I’d like a cleaner solution, if there is one.
Say I have three c-style strings, char buf_1[1024] , char buf_2[1024] , and char
Share
It sounds like you want the reentrant version of
strtok,strtok_rwhich uses a third parameter to save its position in the string instead of a static variable in the function.Here’s some example skeleton code: