home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / tools / isIn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  922 b   |  38 lines

  1. /*------------------------------------------------------------------------
  2.  * $Id: isIn.c,v 1.1 1994/01/20 19:54:08 carlson Exp $
  3.  *
  4.  * This program checks if the first parameter is in any of the following
  5.  * parameters and returns 0 if it is, or 1 if it isn't.
  6.  *
  7.  * Revision History:
  8.  *    $Log: isIn.c,v $
  9.  * Revision 1.1  1994/01/20  19:54:08  carlson
  10.  * Initial revision
  11.  *
  12.  *------------------------------------------------------------------------*/
  13.  
  14. #include <stdio.h>
  15. #include <errno.h>
  16. #include <string.h>
  17.  
  18. main (int argc, char *argv[])
  19. {
  20.     char        **argN;
  21.  
  22.     if (argc < 1)
  23.     {
  24.     fprintf (stderr, "Usage: isIn <string> <string1> [<stringN>]*\n");
  25.     fprintf (stderr, "       Returns 0 if <string> is the same as any\n");
  26.     fprintf (stderr, "       of the other parameters.\n");
  27.     return 0;
  28.     }
  29.  
  30.     for (argN = &argv[2]; *argN; argN++)
  31.     {
  32.     if (strcmp (argv[1], *argN) == 0)
  33.         return 1;
  34.     }
  35.  
  36.     return 0;
  37. }
  38.