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
;
}
查看全文
相关阅读:
docker运行jar包
jQuery动态添加元素并绑定事件
Ubuntu将软件(Sublime Text 2为例)锁定到启动器
jQuery实现列表自动滚动
浅谈css中的position属性
关于jQuery中.attr()和.prop()的问题
Python_opencv库
Python_faker (伪装者)创建假数据
Python_Tips_dumpload 和 dumpsloads 的区别与联系
Linux_CentOS 7下Nginx服务器的安装配置
原文地址:https://www.cnblogs.com/ahuo/p/1210704.html
最新文章
对象方法
数组方法合集
Css3的Media Query 媒体查询 方法总结—让您的网站兼容手机
touchweb网站常见问题,手机网站注意问题
http1.0和http1.1及http2.0区别
跨域解决方案
前端工程化
高级前端面试题 重要
高级前端面试题 js 2
loadrunner—web_url
热门文章
NSIS录制基础脚本,制作安装包
application配置项
重命名 docker 容器名
docker中部署springboot项目,并且外部访问
Linux CentOS下安装docker
Linux下安装Java(JDK8)
oracle Vm cirtualbox创建linux虚拟机
Linux下安装java
VMware安装Centos7超详细过程(图文)
nginx
Copyright © 2011-2022 走看看