//字符串拷贝,排除指定字符
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. POJ2836 Rectangular Covering(状压DP)

    题目是平面上n个点,要用若干个矩形盖住它们,每个矩形上至少要包含2个点,问要用的矩形的面积和最少是多少. 容易反证得出每个矩形上四个角必定至少覆盖了两个点.然后就状压DP: dp[S]表示覆盖的点集为 ...

  2. HDU2824 The Euler function(欧拉函数)

    题目求φ(a)+φ(a+1)+...+φ(b-1)+φ(b). 用欧拉筛选法O(n)计算出n以内的φ值,存个前缀和即可. φ(p)=p-1(p是质数),小于这个质数且与其互质的个数就是p-1: φ(p ...

  3. 斐波那契数[XDU1049]

    Problem 1049 - 斐波那契数 Time Limit: 1000MS   Memory Limit: 65536KB   Difficulty: Total Submit: 1673  Ac ...

  4. 坑爹的strcat

    strcat是会改变原来的字符型数组的值的. #include<stdio.h> #include<stdlib.h> #include<string.h> voi ...

  5. hdu 3348 coins

    这道题算是一道很经典的题,很好的诠释了贪心和动态规划的不同功能.求最少钱的数量用贪心就够了,但是求最多钱的数量要用到动态规划的思想,每步都尽量保留最大 数量.具体看程序注解: #include&quo ...

  6. android之打开网页

    首先改写strings.xml文件 代码如下: <resources> <string name="app_name">Intent应用</strin ...

  7. 连连看的设计与实现——四人小组项目(GUI)

    项目GUI界面经过简单设计,整理如下:(图片截取致宠物连连看3.1) 点开游戏后界面显示: 点击菜单游戏—>初级 后显示 -------------------------- > 当游戏时 ...

  8. POJ 3468 A Simple Problem with Integers(线段树区间更新区间查询)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 92632   ...

  9. Centos 如何安装Django环境

    Centos 如何安装Django环境 | 浏览:954 | 更新:2014-10-31 20:34 针对Centos这一Linux发行版,进行django环境的搭建过程介绍.   工具/原料 Cen ...

  10. thinkphp四种url访问方式详解

    本文实例分析了thinkphp的四种url访问方式.分享给大家供大家参考.具体分析如下: 一.什么是MVC thinkphp的MVC模式非常灵活,即使只有三个中和一个也可以运行. M -Model 编 ...