/* splitarg.c (emx+gcc) */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (void)
{
  char buf[1000], *p, **av;
  int i, n;

  while (fgets (buf, sizeof (buf), stdin) != NULL)
    {
      p = strchr (buf, '\n');
      if (p != NULL) *p = 0;
      av = _splitargs (buf, &n);
      if (av == NULL)
        perror ("_splitargs");
      else
        {
          for (i = 0; i < n; ++i)
            printf ("argv[%d] = |%s|\n", i, av[i]);
          if (av[n] != NULL)
            printf ("Last pointer is not NULL\n");
          free (av);
        }
    }
  return 0;
}
