utils

useful C functions with no dependencies
git clone https://github.com/TanguyAndreani/utils
Log | Files | Refs

basic_getopt.c (332B)


      1 char basic_getopt(int ac, char *av[])
      2 {
      3     static int i = 0, j = 1;
      4 
      5     if (i >= ac)
      6         return (-1);
      7 
      8     if (!av[i][j]) {
      9         j = 1;
     10         i++;
     11         return (basic_getopt(ac, av));
     12     }
     13 
     14     if (av[i][0] == '-') {
     15         char c = av[i][j++];
     16         return (c);
     17     }
     18 
     19     i++;
     20     return (basic_getopt(ac, av));
     21 }