//字符串拷贝,排除指定字符
char *strcpy_exclude_char(char *dst, const int dst_len, const char *src, const char *exclude_list)
{
int i = , j = , flag = ;
const char *p = NULL;
if (dst == NULL && src == NULL)return NULL;
if (dst == src)return dst;
for (; j < dst_len && src[i] != '\0'; ++i)
{
flag = ;
p = exclude_list;
while (p && *p != '\0')
{
if (*p == src[i]){ flag = ; break; }
p++;
}
if (flag == )dst[j++] = src[i];
}
dst[j] = '\0';
return dst;
}
 //字符串拷贝,替换指定字符
char *strcpy_replace_char(char *dst, const int dst_len, const char *src, char aim, char rep)
{
int i = ;
if (dst == NULL && src == NULL)return NULL;
if (dst == src)return dst;
for (; i < dst_len && src[i] != '\0'; ++i)
{
if (src[i] == aim)
{
dst[i] = rep;
}
else
{
dst[i] = src[i];
}
}
dst[i] = '\0';
return dst;
}
//字符串原址替换指定字符
char * str_replace_char(char *dst, char aim, char rep)
{
int i = ;
if (dst == NULL)return NULL;
for (; dst[i] != '\0';++i)
{
if (dst[i] == aim)
{
dst[i] = rep;
}
}
return dst;
}

C++ 字符串操作常见函数的更多相关文章

  1. python学习笔记(字符串操作、字典操作、三级菜单实例)

    字符串操作 name = "alex" print(name.capitalize()) #首字母大写 name = "my name is alex" pri ...

  2. shell编程常用的截取字符串操作

    1.          常用的字符串操作 1.1.           替换字符串:$ echo ${var/ /_}#支持正怎表达式 / /表示搜索到第一个替换,// /表示搜索到的结果全部替换. ...

  3. php字符串操作集锦

    web操作, 主要就是对字符文本信息进行处理, 所以, 字符串操作几乎占了很大一部分的php操作.包括 注意strstr 和 strtr的区别? 前者表示字符串查找返回字符串,后者表示字符串中字符替换 ...

  4. java 字符串操作和日期操作

    一.字符串操作 创建字符串 String s2 = new String("Hello World"); String s1 = "Hello World"; ...

  5. [No000078]Python3 字符串操作

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...

  6. Python 字符串操作及string模块使用

    python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求: python的字符串属性函数 python的string模块 1.字符串属性方法操作: 1.>字符串格式输出对 ...

  7. C语言字符串操作总结大全

    1)字符串操作 strcpy(p, p1)  复制字符串  函数原型strncpy(p, p1, n)   复制指定长度字符串  函数原型strcat(p, p1)   附加字符串  函数原型strn ...

  8. c# 字符串操作

    一.字符串操作 //字符串转数组 string mystring="this is a string" char[] mychars=mystring.ToCharArray(); ...

  9. C语言字符串操作总结大全(超详细)

    本篇文章是对C语言字符串操作进行了详细的总结分析,需要的朋友参考下 1)字符串操作  strcpy(p, p1) 复制字符串  strncpy(p, p1, n) 复制指定长度字符串  strcat( ...

随机推荐

  1. 计算几何 2013年山东省赛 A Rescue The Princess

    题目传送门 /* 已知一向量为(x , y) 则将它旋转θ后的坐标为(x*cosθ- y * sinθ , y*cosθ + x * sinθ) 应用到本题,x变为(xb - xa), y变为(yb ...

  2. LightOJ1068 Investigation(数位DP)

    这题要求区间有多少个模K且各位数之和模K都等于0的数字. 注意到[1,231]这些数最大的各位数之和不会超过90左右,而如果K大于90那么模K的结果肯定不是0,因此K大于90就没有解. 考虑到数据规模 ...

  3. 基于Extjs的web表单设计器 第七节——取数公式设计之取数公式的使用

    基于Extjs的web表单设计器 基于Extjs的web表单设计器 第一节 基于Extjs的web表单设计器 第二节——表单控件设计 基于Extjs的web表单设计器 第三节——控件拖放 基于Extj ...

  4. CSGrandeur的WebGL学习——WebGL教程

    在线查看:http://csgrandeur.gitbooks.io/webgl-learn/content/ 离线mobi:http://files.cnblogs.com/files/CSGran ...

  5. Complete the Sequence[HDU1121]

    Complete the Sequence Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  6. BZOJ3498 : PA2009 Cakes

    令三元环(i,j,k)中i>j>k,则每条边只需要从大点连向小点 设d[x]表示从x连出的边的条数 从1到n枚举点i,然后枚举所有与i相连的边(i,x)(x<i) 如果$d[x]\l ...

  7. HDU 2896 (AC自动机模板题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2896 题目大意:多个模式串.多个匹配串.其中串的字符范围是(0~127).问匹配串中含有哪几个模式串 ...

  8. Codeforces Round #199 (Div. 2) A Xenia and Divisors

    注意题目的数字最大是7 而能整除的只有 1,2,3,4,6,故构成的组合只能是1,2,4 或1,2,6或1,3,6,故分别统计1,2,3,4,6的个数,然后再分配 #include <iostr ...

  9. 转载 从最简单的vector中sort用法到自定义比较函数comp后对结构体排序的sort算法

    转载自:http://www.cnblogs.com/cj695/p/3863142.html sort函数在使用中非常好用,也非常简单,而且效率与冒泡或者选择排序不是一个数量级.本文就sort函数在 ...

  10. spark Mllib SVM实例

    Mllib SVM实例 1.数据 数据格式为:标签, 特征1 特征2 特征3…… 0 128:51 129:159 130:253 131:159 132:50 155:48 156:238 157: ...