zoukankan
html css js c++ java
c++字符串等长替换函数
//
Replace.cpp : Defines the entry point for the console application.
//
#include
"
stdafx.h
"
#include
<
shlwapi.h
>
#pragma
comment(lib,"shlwapi.lib")
int
StrReplaceI(
char
*
src,
char
*
oldstr,
char
*
newstr)
{
if
(
!
src)
{
return
1
;
}
int
oldlen
=
strlen(oldstr);
int
newlen
=
strlen(newstr);
if
(newlen
>
oldlen)
{
return
2
;
}
char
*
pold
=
StrStrI(src,oldstr);
if
(
!
pold)
{
return
3
;
}
memset(pold,
'
'
,oldlen);
memcpy(pold,newstr,newlen);
return
0
;
}
int
main(
int
argc,
char
*
argv[])
{
printf(
"
Hello World!\n
"
);
char
buf[]
=
"
1234 567 890
"
;
StrReplaceI(buf,
"
567
"
,
"
99
"
);
printf(
"
%s\n
"
,buf);
return
0
;
}
查看全文
相关阅读:
【原创】C++11:左值和右值(深度分析)
【基础核心理论】运算符重载
左值与右值引用 详解
托盘图标编程
C/C++ 数组与指针
webpack 4.0改版问题
mysql5.7安装记录
equals方法
【原创】IO流:读写操作研究(输入流)
为什么重写equals一定要重写hashCode?
原文地址:https://www.cnblogs.com/ahuo/p/1210704.html
最新文章
将dos格式文件转换为unix格式
apache ignite系列(四):持久化
08-2 面向对象进阶
08-1 面向对象基础
003 mysql中exists的使用
002 元类的创建及简单使用
timeit模块
numpy/pandas/matplotlib模块
面向对象补充
Django线上部署教程:腾讯云+Ubuntu+Django+Uwsgi(转载)
热门文章
SSH命令行传输文件到远程服务器
从 PC 卸载 Office
理财2
理财0
理财1
50首音乐,喝茶时听一听,身心舒畅
shell一出手
MySQL 详细学习笔记
MariaDB ColumnStore初探(1):安装、使用及测试
Redis 高级特性
Copyright © 2011-2022 走看看