index.c

来自「speech signal process tools」· C语言 代码 · 共 32 行

C
32
字号
/* static char Sccsid[]="@(#)index.c	1.2 12/8/89 ESI, ATT"; *//*	If `s2' is a substring of `s1' return the offset of the first	occurrence of `s2' in `s1',	else return -1.*/int index(as1,as2)char *as1,*as2;{	register char *s1,*s2,c;	int offset;	s1 = as1;	s2 = as2;	c = *s2;	while (*s1)		if (*s1++ == c) {			offset = s1 - as1 - 1;			s2++;			while ((c = *s2++) == *s1++ && c) ;			if (c == 0)				return(offset);			s1 = offset + as1 + 1;			s2 = as2;			c = *s2;		}	 return(-1);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?