How do I complete K&R Exercise 2-4?

前端 未结 5 558
Happy的楠姐
Happy的楠姐 2020-12-18 14:49

I\'m learning how to write programs in C using the k&r book (The C Programming Language) and I have a problem with one of the exercises. It\'s asking me to detect and re

5条回答
  •  难免孤独
    2020-12-18 15:25

    void squeeze(char s1[], char s2[])
    {
        int i,j,k;
        char c;
        for(i=0;s2[i]!='\0';i++)
        {
            c=s2[i];
            for(j=k=0;s1[j]!='\0';j++)
                if(s1[j]!=c)
                    s1[k++]=s1[j];
                s1[k]='\0';
        }
    }
    

提交回复
热议问题