/* This is a function that returns the postion of a substring t within the string s. This version, copied from page 67 of Kernighan and Ritchie, is functionally equivalent to the UNIX System V function, strcspn. The only difference is the return value when t is not found withing s. The position of the substring is returned if found, if not -1 is returned. */ int sindex(s,t) char s[], t[]; { int i, j, k; for ( i=0; s[i] != '\0'; i++ ) { for ( j=i, k=0; t[k] != '\0' && s[j] == t[k]; j++, k++ ) ; if (t[k] == '\0') return(i); } return(-1); }