148. Program to delete a character from a string.
#include<stdio.h>
char
s[10],ch;
int
i,j;
void
main()
{
printf("Enter string 1 : ");
scanf("%s",s);
printf("Enter character to delete :
");
scanf(" %c",&ch);
for(i=0;s[i];i++)
{
if(s[i]==ch)
{
for(j=i;s[j];j++)
s[j]=s[j+1];
i--;
}
}
printf("%s",s);
}
Comments
Post a Comment