Search



Wednesday, 4 March 2015

Removing Characters in string except alphabet

#include<stdio.h>
#include<conio.h>
void main()
{ char line[100];
int i,j;
clrscr();
printf("\n\n Program to remove all characters of string except alphabets");
printf("\n Enter a string: ");
gets(line);
for(i=0; line[i]!='\0'; i++)
{ while (!((line[i]>='a' && line[i]<='z') || (line[i]>='A'&&line[i]<='Z' || line[i]=='\0')))
{ for(j=i;line[j]!='\0';j++)
{ line[j]=line[j+1];
}
line[j] = '\0';
}
}
printf("\n Output of String : ");
puts(line);
getch();
}

No comments:

Post a Comment

Guys if you think something is wrong or should be edit than please do comment.