C program-To remove vowel from string

Posted: January 13, 2012 in Lab 1
#include<stdio.h>
void main()
{
char a[21],b[21],*ptr;
int i=0;
printf("Enter string:");
gets(a);
ptr=a;
for(;*ptr!='\0';ptr++)
{
if(*ptr!='a'&&*ptr!='e'&&*ptr!='i'&&*ptr!='o'&&*ptr!='u'&&*ptr!='A'&&*ptr!='E'&&*ptr!='I'&&*ptr!='O'&&*ptr!='U')
{
*(b+i)=*ptr;
i++;
}
*(b+i)='\0';
}
printf("\n String after removing vowels:\n");
puts(b);
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s