第1个回答 推荐于2018-04-06
#include <stdio.h>
void main()
{
char s[100];
char *p,*q;
printf("Please input a string:\n");
scanf("%s", s);
p=s;
while(*p && *p!='c') p++;
q=p;
while(*q)
{
if(*q!='c') *p++=*q;
q++;
}
*p='\0';
printf("The result is:\n");
printf("%s", s);
}本回答被提问者和网友采纳
第2个回答 2008-05-15
c++的成不?
#include<string>
int main()
{
std::string input;
//输入字符串
std::cin>>input;
//查找字符c
size_t pos=input.find('c');
while(pos!=std::string::npos)
{
input.erase(pos,1);//删除c
pos=input.find('c',pos);//查找下一个c
}
std::cout<<input;
}
第3个回答 2008-05-15
#include <stdio.h>
#include <string.h>
void main()
{
char s1[100],s2[100];
int i,j,k;
char temp;
printf("Please input a string:\n");
gets(s1);
printf("Please input what you want to delete:\n");
gets(s2);
for(i=0;i<strlen(s2);i++)
{
temp=s2[i];
j=0;
while(s1[j]!='\0')
{
if(s1[j]==temp)
{
k=j;
while(s1[k]!='\0')
{
s1[k]=s1[k+1];
k++;
}
}
j++;
}
}
printf("The result is:\n");
puts(s1);
}
第4个回答 2019-09-14
#include
<stdio.h>
void
main()
{
char
s[100];
char
*p,*q;
printf("Please
input
a
string:\n");
scanf("%s",
s);
p=s;
while(*p
&&
*p!='c')
p++;
q=p;
while(*q)
{
if(*q!='c')
*p++=*q;
q++;
}
*p='\0';
printf("The
result
is:\n");
printf("%s",
s);
}
第5个回答 2008-05-15
#include<stdio.h>
#include<conio.h>
main()
{
int i = 0;
char c = 'a';
char s[256];
memset(s, 0x00, sizeof(s));
while (1)
{
s[i] = getch();
printf(&(s[i]));
if (s[i] == c)
i--;
if (s[i] == '\r')
break;
i++;
}
printf("\nnew string: ");
printf(s);
getch();
}