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
;
}
查看全文
相关阅读:
通过POST请求上传文件
接口测试及常用接口测试工具
maven-surefire-plugin插件
BDD框架之Cucumber研究
一分钟认识:Cucumber框架
ACM团队周赛题解(3)
C++11新增容器以及元组
ACM团队周赛题解(2)
C++11部分特性
ACM团队周赛题解(1)
原文地址:https://www.cnblogs.com/ahuo/p/1210704.html
最新文章
转- 阿里云、Amazon、Google云数据库方案架构与技术分析
test
DeepMind背后的人工智能:深度学习原理初探
ceph hadoop spark 大数据处理
如何提交代码到CEPH Repo。 顺便庆祝下,提交了第一个ceph pull request。实现了从0到1的突破
运维-技术栈
运维-nginx +php 错误状态码说明
运维-kibana常用查询使用
运维-安装rabbitmq 集群
安装-supervisor
热门文章
安装-consul服务发现集群
安装kafka + zookeeper集群
Storm集群安装部署步骤【详细版】
阿里云 API 签名机制的 Python 实现
atlassian-confluence
零基础学习hadoop到上手工作线路指导(中级篇)
[学习线路] 零基础学习hadoop到上手工作线路指导(初级篇)
Zookeeper学习
Hadoop概念学习系列之Hadoop、Spark学习路线(很值得推荐)
HttpClient使用详解
Copyright © 2011-2022 走看看