home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / JPLC2.ZIP / STRINDEX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-22  |  827 b   |  32 lines

  1. /* 1.0  07-06-84 */
  2. /************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1984        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10.  
  11. /************************************************************************/
  12.  
  13. strindex(s, t)        /* return the index of t in s, -1 if none.    */
  14.  
  15. /*----------------------------------------------------------------------*/
  16. STRING s, t;
  17. {
  18.     int i, j, k;
  19.  
  20.     for (i = 0; s[i] ISNT NULL; i++)
  21.     {    for (j = i, k = 0; t[k] ISNT NULL AND s[j] IS t[k]; j++, k++)
  22.             ;
  23.         if (t[k] IS NULL)
  24.             return (i);
  25.     }
  26.     return (EOF);
  27. }
  28.  
  29. /*    This is the index(s,t) function given in Kernighan and Ritchie,
  30.  *    page 67.
  31.  */
  32.