| Current Path : /var/www/html/venkat/old/old/ |
| Current File : /var/www/html/venkat/old/old/lit2015035_3.c |
//Write a function in a program to keep only characters in a string and remove the numerals.
#include<stdio.h>
#include<ctype.h>
void removenumeral(char *);
int main()
{
char str[100];
printf("Enter a string:");
scanf("%s",str);
removenumeral(str);
printf("%s",str);
return 0;
}
//This function remove numerals in the string str
void removenumeral(char str[100])
{
int i=0,j=0;
char temp[100];//this array of characters will store the string str without numbers in it
while(str[i]!='\0')
{
if(isalpha(str[i]))
{
temp[j]=str[i];
j++;
}
i++;
}
temp[j]='\0';
//the string temp is now copied to original string str
i=0;
while(str[i]!='\0')
{
str[i]=temp[i];
i++;
}
str[i]='\0';
}