Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char **tokenizal(const char *delim, const char *string){
- char **t;
- char *d1, *s1 = string, *st = string;
- int n = 1, m = 0, i = 0, ok;
- while(*s1){
- ok = 0;
- d1 = delim;
- while(*d1 && !ok){
- if(*s1 == *d1){
- ok = 1;
- n++;
- }
- d1++;
- }
- s1++;
- }
- t = (char**)malloc((n+2) * sizeof(char*));
- s1 = string;
- ok = 0;
- i = 0;
- do{
- d1 = delim;
- if(*s1){
- while(*d1 && !ok){
- if(*s1 == *d1)
- ok = 1;
- d1++;
- }
- } else ok = 1;
- if(ok){
- char *tmp;
- ok = 0;
- if(s1-st > 0){
- tmp = (char *)malloc(s1-st+1);
- t[i] = tmp;
- while(st != s1) *tmp++ = *st++;
- *tmp = 0;
- st++;
- i++;
- } else st++;
- }
- }while(*s1++);
- t[i] = NULL;
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement