c语言编程 删除一字符串中的所有*号

急 啊 高手请写的简明一点

#include <stdio.h>
int main()
{
    char s[100];
    int i,j;
    gets(s);
    for(i=0,j=0;s[i]!='\0';i++)
    {
        if(s[i]!='*')
            s[j++]=s[i];
    }
    s[j]='\0';
    printf("%s",s);
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-06-24
#include <stdio.h>

int main(void)
{
    char buf[] = "**32*ab*deo***dkla*";
    int i, j = 0;
    
    for (i=0; buf[i]; i++) {    // 遍历字符串
        if (buf[i] != '*') {    // 只要不是*号
            buf[j++] = buf[i];  // 执行一次移动, 可以共用一个buf

        }
    }
    
    buf[j] = 0;            // 置结束符
    
    return 0;
}

第2个回答  2013-06-24
#include<stdio.h>
#include<string.h>
char fun(char *a)
{
int i = 0, j = 0, len, len2;
char b[80];
len = strlen(a);
for (i = 0; i < len; i++)
if (a[i] != '*')
{
b[j] = a[i];
j++;
}
len2 = strlen(b);
for (i = 0; i < len2; i++)
a[i] = b[i];
a[i] = '\0';
}

int main()
{
char a[80];
printf("Enter char:");
gets(a);
fun(a);
printf("The result is:");
puts(a);
}
祝你愉快!本回答被提问者采纳
第3个回答  2013-06-24
#include <stdio.h>
int main()
{
   char s[100];
   int i=0;
   gets(s);
   while(s[i++]!='\0')
   if(s[i]!='*')
       printf("%c",s[i]);
}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网