简单c问题,请高手改错

来源:百度知道 编辑:UC知道 时间:2024/06/19 14:28:57
题目是:把一字符串中的小写字母c去掉
#include"stdio.h"
fun(char *s)
{int i,j=0;
for(i=0;i!='\0';i++)
while(s[i]=='c')
s[j++]=s[i++];
return s;
}
main()
{char *s;
printf("input s:");
scanf("%s",s);
printf("the string is %s",fun(s));
}

#include"stdio.h"
fun(char *s)
{
int i,j=0;
for(i=0;s[i]!='\0';i++)
if(s[i]!='c')
s[j++]=s[i];
s[j]='\0'; //截断后面的数据
return s;
}
main()
{
char *s;
printf("input s:");
scanf("%s",s);
printf("the string is %s",fun(s));
}//至于编译器提示的错误可以不管它,只要程序要能够保证其正确性就可以了

#include <stdio.h>

void fun(char *s){
int i,j;
int repeat=1;
for(i=0;s[i]!='\0';i++,repeat=1){
while(repeat){
if(s[i]=='c'){
j=i;
while(s[j]!='\0') {s[j]=s[j+1];j++;}
s[j-1]='\0';
}/*if*/
if(s[i]!='c') repeat=0;
}/*while repeat*/
}/*for*/
}

void main(){
char s[80];
puts("input s:");
scanf("%s",s);
fu