strstr.c
来自「cygwin, 著名的在win32下模拟unix操作系统的东东」· C语言 代码 · 共 74 行
C
74 行
/*FUNCTION <<strstr>>---find string segmentINDEX strstrANSI_SYNOPSIS #include <string.h> char *strstr(const char *<[s1]>, const char *<[s2]>);TRAD_SYNOPSIS #include <string.h> char *strstr(<[s1]>, <[s2]>) char *<[s1]>; char *<[s2]>;DESCRIPTION Locates the first occurence in the string pointed to by <[s1]> of the sequence of characters in the string pointed to by <[s2]> (excluding the terminating null character).RETURNS Returns a pointer to the located string segment, or a null pointer if the string <[s2]> is not found. If <[s2]> points to a string with zero length, the <[s1]> is returned.PORTABILITY<<strstr>> is ANSI C.<<strstr>> requires no supporting OS subroutines.QUICKREF strstr ansi pure*/#include <string.h>char *_DEFUN (strstr, (searchee, lookfor), _CONST char *searchee _AND _CONST char *lookfor){ if (*searchee == 0) { if (*lookfor) return (char *) NULL; return (char *) searchee; } while (*searchee) { size_t i; i = 0; while (1) { if (lookfor[i] == 0) { return (char *) searchee; } if (lookfor[i] != searchee[i]) { break; } i++; } searchee++; } return (char *) NULL;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?