C Program to delete all the occurences of the particular character in the given string..

#include<stdio.h>
#include<string.h>


char* deletecharofstring(char *a, char t)
{
 static char b[50];
 int i=0,j=0;
 while(a[i]!='\0')
 {
   if(a[i]!=t)
     {
      b[j]=a[i];
      j++;
     }
   i++;
 }
 return b;
}

void main()
{
 char a[50],t,*ans;
  printf("Enter the String..");
 scanf("%s",a);
 getchar();
 printf("\nEnter the character to delete..");
 scanf("%c",&t);
 ans=deletecharofstring(a,t);
 printf("\nThe modified string is..%s",ans);
}


No comments:

Post a comment