I Have tried to implement a function which splits an incoming string into 5 arguments using the strtok_r function
I could still be wrong here, iv'e only been learning C for around 3 months, but i copied it into another char array first then pointed to that as strtok_r takes a pointer for its first argument? char copiedstr;, or have I misunderstood something,
s3 : Is a value-return parameter used by strtok_r() to record its progress through s1.
char *saveptr1, *saveptr2, *saveptr3, *saveptr4, *saveptr5; str1 = sstring; cmd = strtok_r(str1, &delim, &saveptr1); ... arg1 = strtok_r(str1, &delim, &saveptr2);... str1 = saveptr2; arg2 = strtok_r(str1, &delim, &saveptr3);... str1 = saveptr3;... arg3 = strtok_r(str1, &delim, &saveptr4);... str1 = saveptr4; arg4 = strtok_r(str1, &delim, &saveptr5);
To get the first token from s1, strtok_r() is called with s1 as its first parameter. Remaining tokens from s1 are obtained by calling strtok_r() with a null pointer for the first parameter.
I just read up a little on regex's and the search and match functions are a little out of context, maybe I was a bit hasty when i quoted "should do the trick" XD is the only documentation available included in the link you posted?
... it first checks the next character in the original array to see if its a '"' (quote) or not, if its a quote it sets the delimiter as a quote and calls strtok_r, and places the quoted string into 1 argument, then i change the delimiter back to a space and before calling strtok_r again it checks if the next character is an quote ...