C program to remove an element 'e' from a string

Code :

#include<stdio.h>
void main()
{
char arr[20];
int i,j;
printf("\nEnter a string :");
scanf("%s",arr);
for(i=0;arr[i]!='\0';i++)
{
if(arr[i]=='e')
{
for(j=i;arr[j]!='\0';j++)
{
arr[j]=arr[j+1];
}
}
}
printf("\n%s",arr);
}
view raw Removestring.c hosted with ❤ by GitHub

Output:
Enter a string hello
hllo

Comments

Popular posts from this blog

C++ programming toll plaza simulation program