书本例子strindex函数
来源:互联网 发布:lvs和nginx的区别 编辑:程序博客网 时间:2024/04/27 15:40
#include <stdio.h>/*对输入的一行字符串做模版匹配,有匹配则输出*/int getline(char line[], int max);int strindex(char source[], char searchfor[]);//#include "subfunctions.h"#define MAXLINE 1000char pattern[] = "ould";int main(){char line[MAXLINE];int found = 0;//不断的读取一行,有模版匹配则输出while(getline(line, MAXLINE) > 0)if(strindex(line, pattern) >= 0){printf("%s", line);found++;}return found;}
#include <stdio.h>int getline(char s[], int lim){int c, i;i = 0;//对最长行和文件结束有单独处理//行的最大长度由存储数组的大小决定//输入从getchar得到while(--lim > 0 && (c = getchar()) != EOF && c != '\n')s[i++] = c;if(c=='\n')s[i++] = c;s[i] = '\0';return i;}
int strindex(char s[], char t[]){int i, j, k;for(i = 0; s[i] != '\0'; i++){//对原来的字符串重新取下标,扫描完做匹配的模版,则匹配成功for(j = i, k = 0; s[j] == t[k]; j++, k++);if(k > 0 && t[k] == '\0')return i;}return -1;}
0 0
- 书本例子strindex函数
- 右序strindex函数
- 书本上的detab函数
- 套接字 学习笔记四 书本例子
- strindex实现
- 第4.1节 编写函数strindex(s,t)判定“该行包含指定的模式”
- 算法竞赛入门经典-书本例子-3-3-竖式计算
- 4.1编写函数strindex(s,t)它返回字符串t在s中最右边出现的位置。如果s中不包含t,则返回-1。
- 4.1编写函数strindex(s,t)它返回字符串t在s中最右边出现的位置。如果s中不包含t,则返回-1。
- 函数例子
- 函数例子
- 学习书本
- 书本整理
- 书本整理
- 书本转移
- 书本转移
- 书本整理
- 书本整理
- UVa 2678 Subsequence / 二分
- Clover
- android Suspicious method call; should probably call "draw" rather than "onDraw"
- uva 10755 - Garbage Heap(最大和问题)
- HBase设计与开发性能优化
- 书本例子strindex函数
- Flex 读写xml文件的方法_Flex
- poj2923 状压记忆化搜索
- 第四届(2013年十月)福建省大学生程序设计竞赛
- Android xml资源文件中@、@android:type、@*、?、@+含义和区别
- Configuring Automatic Debugging
- 右序strindex函数
- synchronized 同步锁
- 书上例子-简单的atof函数