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
;
}
查看全文
相关阅读:
apue 第19章 伪终端
apue 第18章 终端I/O
linux IPC socket(2)
linux IPC socket
linux POSIX信号量
【Luogu】【关卡2-16】线性动态规划(2017年10月)【还差三道题】
【Luogu】【关卡2-15】动态规划的背包问题(2017年10月)【还差一道题】
【Luogu】【关卡2-14】 树形数据结构(2017年10月)【AK】
【Luogu】【关卡2-13】线性数据结构(2017年10月)【还差一道题】
【Luogu】【关卡2-12】递推与递归二分(2017年10月)
原文地址:https://www.cnblogs.com/ahuo/p/1210704.html
最新文章
shell语句
shell变量
shell基本命令
tomcat使用及集群
curl开发遇到协议不支持问题排查
curl发送SMTP邮件类
状态设计模式笔记
Qt开发MySQL程序发布后出现"Driver not loaded"的问题
UNP学习第三章
【unp】unix网络编程卷1-->环境搭建(ubuntu14.04)
热门文章
linux IPC socket(3)server简单写法
Qt 无法连接mysql数据库的问题
QTcpSocket学习
在树莓派3B上搭建LAMP
Qt installer framework学习
apue 第10章 信号signal
apue 第4章 文件和目录
apue 第6章 系统数据文件和信息
printf 输出格式设置 33[47 33[5m 与-8.8s
QT树莓派交叉编译开发环境搭建
Copyright © 2011-2022 走看看