从字符串中删除字符的方法?

来源:百度知道 编辑:UC知道 时间:2024/05/31 05:25:12
前提不知道字符串长度
譬如要删除 sjhdajhkjhs 中的s

我的想法是
#include<stdio.h>
char sh(char x[])
{
char s='s';
int i;
for(i=0;i<9;++)
if(s=a[i]) 但是找到字符串以后 我不知道怎么弄了

}
main()
{
char s1[7],s2[9]={"sjdfhgysb"};
s1[7]=sh(s);
printf("%c",s1)
}
还要求各位大虾罗列下删除字符串中字符的方法。。

#include <stdio.h>
#include <conio.h>
void main()
{
char s[80],ch;
int i,j=0;
printf("Please input a string:");/*输入一个字符串*/
gets(s);
printf("please input a character:"); /*输入你想删除的那个字符*/
ch=getchar();
for(i=0;s[i]!='\0';i++)
if(s[i]!=ch)
s[j++]=s[i];
s[j]='\0';
printf("%s\n",s);/*输出删除指定字符后的字符串*/
getch();
}
这样你可以删除任何你想删除的字符。

不清楚

可以 把字符串存到一个链表中 链表的删除会吧
或者直接存到数组里 删除 然后把后面的移到前面就是了

不知道!谢谢采纳!