Skip to content

Instantly share code, notes, and snippets.

@upa
Created September 20, 2013 08:26
Show Gist options
  • Select an option

  • Save upa/6634704 to your computer and use it in GitHub Desktop.

Select an option

Save upa/6634704 to your computer and use it in GitHub Desktop.
strsplit
int
strsplit (char * str, char ** args, int max)
{
int argc;
char * c;
for (argc = 0, c = str; *c == ' '; c++);
while (*c && argc < max) {
args[argc++] = c;
while (*c && *c > ' ') c++;
while (*c && *c <= ' ') *c++ = '\0';
}
return argc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment