📄 instr.c
字号:
/* instr.c By Bill Kendrick New Breed Software kendrick@zippy.sonoma.edu http://zippy.sonoma.edu/kendrick/ June 27, 1996 - June 27, 1996 Added #include <string.h> - Sept. 22, 1997*/#include <string.h>#include "instr.h"/* Returns the location within "string" that "word" begins, or -1. */int instr(char * string, char * word){ int i, far, started, found; found = 0; started = -1; far = 0; if ((strlen(word) != 0) && (strlen(word) <= strlen(string))) { for (i = 0; i < strlen(string); i++) { if (string[i] == word[far]) { if (started == -1) started = i; far = far + 1; if (far == strlen(word)) { found = 1; far = 0; } } else { if (found == 0) { far = 0; started = -1; } } } } /* Make sure we found the WHOLE word, not just the beginning! */ if (found == 0) started = -1; return(started);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -