// 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++字符串等长替换函数
原创
©著作权归作者所有:来自51CTO博客作者ahuoheng的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:光电耦合器
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【C语言加油站】详细解读字符函数与字符串函数
【C语言加油站】字符函数与字符串函数详细介绍字符函数与字符串函数的相关知识点……
C语言 字符串 字符函数 字符串函数 -
c++(字符串处理函数)
<br /> <br />#include <iostream.h><br />#include <string.h><br />void main(void)<br />{
c++ buffer string less include -
string替换所有指定字符串(C++)
C++的
字符串 #include ios -
C++ | C++字符串
C++字符串C++ 提供了以下两种类型的字符串表示形式:C 风格字符串C++ 引入的 str
c++ 字符串 #include g++