/* * i n d e x . c */ /*)LIBRARY */ #ifdef DOCUMENTATION title index Get index of character in string index Get index of character in string synopsis index(s,c) char s[]; char c; description The function index(s,c) returns the index in the string pointed to by s of the character c - i.e., s[index(s,c)] is the first c in s. If c does not occur in s, index() returns -1. bugs author Jerry Leichter #endif /* * )EDITLEVEL = 05 * Edit history * 0.0 1-May-81 JSL Invention * 0.1 27-May-81 JSL Conversion to new comment conventions */ #define EOS '\0' index(s,c) register char c; char s[]; { register char *pc; for (pc=s; *pc != c && *pc;) pc++; if (*pc || c == EOS) return(pc - s); else return(-1); }