当前位置:网站首页>remove函数的实现
remove函数的实现
2022-07-22 20:42:00 【QQ851301776】
唉,一个低级失误啊,少了一个等号,逻辑判断变成了一个赋值唉
//实现函数void remove(char* str1, char* str2)。
//功能:将str2里出现的字符从str1里移除。(例如str1为”abcdef”, str2为”bde”,则移除后str1变为”acf”。
void remove(char* str1, char* str2)
{
if((!str1) || (!str2)) return ;
char *tmp = (char *)malloc(strlen(str1)+1);
if(!tmp) return ;
int i, j;
int m = 0;
for(i=0; i< strlen(str1); i++)
{
int k = 0;
for(j = 0; j < strlen(str2); j++)
{
if(str1[i] == str2[j]) k++;
}
if(k == 0)
{
tmp[m++] = str1[i];
}
}
memcpy(str1, tmp, m);
str1[m] = '\0';
free(tmp);
tmp = NULL;
return;
}第一次写的时候,把

边栏推荐
- Inside the hard core of LAN SDN technology - 14 three from things to people - SDN enters the campus network
- 小程序毕设作品之微信酒店预订小程序毕业设计(7)中期检查报告
- 低代码服务商ClickPaaS与毕普科技完成战略合并,共同打造工业数字化底座
- Interface Fiddler introduction and installation
- C language program environment
- After 100 billion of revenue, Alibaba cloud ecosystem has a new way to play
- "The time of a takeaway is not as valuable as that of a programmer": treat yourself as a person after reading a book? Power on
- Daily question brushing record (XXXI)
- LaTeX编写中文实验进展汇报
- gnu 伪指令定义函数
猜你喜欢
随机推荐
redis基本类型常用命令
uniapp切换tab栏显示不同页面并记住页面位置和上拉获取新数据
Detailed explanation of session, cookie and token
Nftscan and ATEM network have reached strategic cooperation in the field of NFT data
0day attack path prediction method based on network defense knowledge map
Stm32cubeide link script explanation
Codeforces Round #808 (Div. 2) A - D
面向商用活体检测平台的鲁棒性评估
【无标题】分享一个基于Abp Vnext开发的API网关项目
Vector3.Lerp
妙用cURL
小程序毕设作品之微信酒店预订小程序毕业设计(6)开题答辩PPT
ES6新增的class类
Redis五大基本数据类型的基本命令
ES6解决异步问题
低代码服务商ClickPaaS与毕普科技完成战略合并,共同打造工业数字化底座
Image processing solution veimagex technology evolution Road
VR全景动物园,成就不一样的动物园名片
Are most programmers eliminated after the age of 45? The truth chilled everyone's heart
C语言 程序环境









