[ create a new paste ] login | about

Link: http://codepad.org/8aWRx8YL    [ raw code | fork ]

C, pasted on Apr 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int split(char* str, char* ret[], char sep, int max) {
  int count = 0;
  char ch;

  do {
    ret[count++]=str;
    if(count >= max) break;
    for(; *str!='\0' && *str!=sep; str++);
    ch=*str;
    *str++='\0';
  } while(ch!='\0');

  return count;
}


Create a new paste based on this one


Comments: