All pastes #200810 Raw Edit

Stuff

public text v1 · immutable
#200810 ·published 2006-10-13 11:53 UTC
rendered paste body

   1.
      char    *get_begin(char *s, char div)
   2.
      {
   3.
       while (*s && (*s == div || *s == ' '))
   4.
         s++;
   5.
       return (s);
   6.
      }
   7.
       
   8.
      char    *get_end(char *s, char div)
   9.
      {
  10.
       while (*s && *s != div)
  11.
         s++;
  12.
       return (s);
  13.
      }
  14.
       
  15.
      char    **my_str_to_wordtab(char *str, char div)
  16.
      {
  17.
       char  *s;
  18.
       char  *fin;
  19.
       int   count;
  20.
       char  **tab;
  21.
       
  22.
       if (!str)
  23.
         return (0);
  24.
       for (s = get_begin(str, div), count = 0; *s; count++)
  25.
         {
  26.
           s = get_end(s, div);
  27.
           s = get_begin(s, div);
  28.
         }
  29.
       tab = malloc((count + 1) * sizeof(fin));
  30.
       for (s = get_begin(str, div), count = 0; *s; count++)
  31.
         {
  32.
           fin = get_end(s, div);
  33.
           tab[count] = my_strndup(s, fin - s);
  34.
           s = fin;
  35.
           s = get_begin(s, div);
  36.
         }
  37.
       tab[count] = 0;
  38.
       return (tab);