home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / emx / test / splitarg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-03  |  618 b   |  30 lines

  1. /* splitarg.c (emx+gcc) */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. int main (void)
  8. {
  9.   char buf[1000], *p, **av;
  10.   int i, n;
  11.  
  12.   while (fgets (buf, sizeof (buf), stdin) != NULL)
  13.     {
  14.       p = strchr (buf, '\n');
  15.       if (p != NULL) *p = 0;
  16.       av = _splitargs (buf, &n);
  17.       if (av == NULL)
  18.         perror ("_splitargs");
  19.       else
  20.         {
  21.           for (i = 0; i < n; ++i)
  22.             printf ("argv[%d] = |%s|\n", i, av[i]);
  23.           if (av[n] != NULL)
  24.             printf ("Last pointer is not NULL\n");
  25.           free (av);
  26.         }
  27.     }
  28.   return (0);
  29. }
  30.