I\'m trying to use this function in a C program that needs to be able to compile in Linux and Windows. At first I tried using strtok_r, but then when I compiled on windows,
Both of these functions are really ugly, unintuitive idioms for parsing strings, and usually fail to meet your particular application's requirements in subtle ways. Even moreso for the plain strtok
in standard C. Just throw them out and write your own code to iterate over the char
array and break it up as needed. strchr
, strspn
, and strcspn
can be helpful in doing this or you can just work from scratch on the array.