字符串中找字符串
来源:互联网 发布:db2数据库 编辑:程序博客网 时间:2024/05/11 15:25
#include <stdio.h>#include <stdlib.h>#include <string.h>int getCount(char *mystr,char *sub,int *ncount){int ret = 0;int tmpCount = 0;char *p = mystr;if(mystr ==NULL || sub==NULL || ncount ==NULL){ret = -1;printf("func getCount() err:%d mystr ==NULL || sub==NULL || ncount ==NULL",ret);return ret;}do {p = strstr(p,sub);if(p!=NULL){tmpCount++;p = p+strlen(sub);}else{break;}}while(*p!='\0');*ncount = tmpCount;return ret;}void main(){int ret = 0;char *p = "abcd1111222abcd";int count = 0;char sub[] = "abcd";ret = getCount(p,sub,&count);if(ret!=0){printf("func getCount() err:%d\n",ret);return ret;}printf("%d",count);}
0 0
- 字符串中找字符串
- 字符串中找数字
- 【C++】字符串中找数字
- 在字符串中找匹配
- 找字符串
- 从字符串中找数字 string 中找digits
- 找一个字符串中最长的整数
- Shell在文件中找指定字符串
- 在一些字符串中找特定字符
- 字符矩阵中找字符串路径
- 21. 微软面试题:字符串中找最长数字字符串
- C语言练习题-字符串中找连续最长字符串
- C语言练习题-字符串中找连续最长字符串
- 找基本组成字符串
- KMP复习 找字符串
- 1325: 字符串找规律
- hdu_4357_找字符串规律
- 1325:字符串找规律
- JavaI/O(一)--字符流
- 孤独与寂寞的存在
- UVA 11255 Necklace(每种颜色珠子个数限制、Polya原理、组合数)
- ImageLoader简单理解
- 快速构建不同UI样式的列表适配器方法-AbsAdapter
- 字符串中找字符串
- Leetcode Repeated DNA Sequences
- 两头堵模型
- HttpsUtil
- 菜鸟的安卓之路。2016.06.10
- 递归的一些逐步理解
- 流程变量
- Nutch抓取错误——java.sql.BatchUpdateException: Incorrect string value: '\xF2\xA3\xAC\xB7\xEF\xBF.
- 自定义空间怎么在context传入activity给空间操作