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
;
}
查看全文
相关阅读:
UML笔记补充——活动图的简单理解(看书过程中看到的经典实例,记录下来,以免忘了)
对UML笔记中状态图的补充
UML笔记(九)
UML笔记(十一)
UML笔记(七)
新的开始——C#
UML笔记(八)
UML笔记(十)
机房收费系统画图总结
Servlet 学习笔记4:HTTP应答状态
原文地址:https://www.cnblogs.com/ahuo/p/1210704.html
最新文章
病情高度活动的RA病人的感染风险增加
中信国健临床通讯 2011年2月第2期
一项横断面研究表明RA达标治疗有利于降低心血管风险
MRI骨水肿是早期未分化关节炎演变为RA的独立预测预测因素
2010 ACR/EULAR 类风湿关节炎分类标准的应用:针对非常早期的滑膜炎患者与1987年ACR标准的比较
比较国际脊柱关节炎学会、欧洲脊椎关节病研究小组和改良的纽约标准对中国脊柱关节病患者的评估作用
POJ1320 Street Numbers pell方程
Codeforces Round #168 (Div. 2)
Codeforces Round #171 (Div. 2)
POJ3590 The shuffle Problem 置换+DP | DFS
热门文章
POJ1322 Chocolate 概率DP
POJ2754 Similarity of necklaces 2 多重背包
POJ2155 Matrix 二维线段树 | 树状数组
POJ3034 WhacaMole DP (trick很坑爹)
POJ3612 Telephone Wire DP+优化
POJ2684 Polygonal Line Search 计算几何基础
POJ1947 Rebuilding Roads 树形DP+分组背包
POJ2353 Ministry 二维DP+优化
POJ2411 Mondriaan's Dream 状态压缩DP
POJ3254 Corn Fields 状态压缩DP+滚动数组
Copyright © 2011-2022 走看看