分享

在字符串删除指定字符

 烧包谷free 2013-09-13

//*************************************************************//
//**  函数名称:                                               //
//**  函数功能:在字符串删除指定字符                           //
//**  作    者:xt                                             //
//**  时    间:2013/8/5                                       //
//*************************************************************//


#include "stdio.h"
#include "string.h"

void main()
{
void deletechr(char s[] , char ch);
char s[100],ch;

gets(s);
ch=getchar();
puts(s);
deletechr(s,ch);
puts(s);
}

void deletechr(char s[] , char ch)
{
int strchr1(char s[] , char ch);
int p;
p=strchr1(s,ch);
if(p!=-1)
{
for(;s[p]!='\0';p++)
s[p]=s[p+1];
}
else
printf("Not found!");
}

int strchr1(char s[] , char ch)
{
int i;
for(i=0;s[i]!='\0';i++)
if(s[i]==ch)
return i;
return -1;
}


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多