📄 sgrep.c
字号:
int getline(char line[], int max);int strindex(char source[], char searchfor[]);int printf(char *fmt, char *);int getchar();char pattern[] = "ould";int main(void){ char line[512]; int found = 0; while (getline(line, 512) > 0) if (strindex(line, pattern) >= 0) { printf("%s", line); found = found + 1; } return found;}/*strindex: 返回t在s中的位置,若未找至则返回-1*/int strindex(char s[], char t[]){ int i, j, k; i = 0; while (s[i] != 0) { j = i; k = 0; while (t[k] != 0) { if (s[j] != t[k]) break; j = j + 1; k = k + 1; } if (k > 0) if (t[k] == 0) return i; i = i + 1; } return -1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -