from a string remove all characters of a given alphabet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jinnejeevansai
    New Member
    • Nov 2014
    • 48

    from a string remove all characters of a given alphabet

    #include<stdio. h>
    int main()
    { int n,i,j=0;
    char a[n],c[n];
    char b;
    scanf("%d",&n);
    scanf("%s",a);
    scanf("%c",&b);
    for(i=0;i<n;i++ )
    {
    if(a[i]!=b)
    {
    c[j]=a[i];
    j++;
    }
    }
    printf("%s",c);
    }

    ~
    ~
    ~
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Please explain a little more. I'm not sure exactly what you want to do.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      I'm surprised you don't get compiler errors for declaring arrays a and c with size equal to uninitialized variable n.
      How do you know the user will enter a value for n that is less than or equal to the length of the string that is entered for a?
      How certain are you that you write a terminating null to array c?

      Comment

      • jinnejeevansai
        New Member
        • Nov 2014
        • 48

        #4
        ok i got the answer to my question

        Comment

        Working...