home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
545a.lha
/
IncRev_v1.03rel3
/
source
/
strpos.c
< prev
Wrap
C/C++ Source or Header
|
1991-09-06
|
1KB
|
43 lines
/***************************************************************************
* strpos.c: returns index of string2 in string1 or -1 if not found *
* *
* initially created somewhen in 1990 *
***************************************************************************/
/* --------------------- source code revisions, tracked by RCS ---------- */
/* $Header: Hard0:C-Compiler/src/increv/rcs/strpos.c,v 1.0.1.2 91/08/12 15:04:19 Mtwx Exp Locker: Mtwx $ */
/* $Log: strpos.c,v $
* Revision 1.0.1.2 91/08/12 15:04:19 Mtwx
* - RCS test, no real change!
*
* Revision 1.0.1.1 91/08/12 15:02:56 Mtwx
* - added (Metalworx-) comments and styles
*
* Revision 1.0 91/08/12 14:59:03 Mtwx
* Initial revision
* */
/* ------------------------------- routines ----------------------------- */
int strpos(s1,s2)
char *s1,*s2;
{
register int i;
int n,pos=0,flag=0;
if(strlen(s2) > strlen(s1)) return -1;
for(i=0;i<strlen(s1)-strlen(s2)+1;i++)
{
n=strncmp(&s1[i],s2,strlen(s2));
if(n==0)
{
pos=i;
flag=1;
break;
}
}
if(!flag) pos=-1;
return pos;
}