ois20t7 progam o dle vowels tom sin | Programing Sinkted
sa Custom Search] search
Home » C programming » C programming examples » C program to delete vowels from a string
C program to delete vowels from a string
Remove vowels from a string in c: ¢ program to remove or delete vowels from a string, if the
input string is "e programming” then output will be "e prgrmmng". In the program we
create a new string and process entered string character by character, and if a vowel is found
it is not added to new string otherwise the character is added to new string, after the string
ends we copy the new string into original string. Finally we obtain a string without any
vowels.
C programming code
include
include
nt. check_vowel(char);
int main()
q
char s[190}, t[100];
Ant 4, J = 0;
printf ("Enter a string to delete vowels\n");
gets(s);
for(i = 0; s[i] I= "0"; i++) {
iF (check_vowel(s[i]) == 8) ¢ J /not @ vowel
t0H] = sli]
See
y
y
‘UJ] = Ne"
strepy(s, t); //We are changing inittal string
print#("string after deleting vowels: %s\n", s);
return 0;
Ant check_vowel(char ¢)
{
switch(e) {
case *A"
case *F
tpn programmingsinplifed.comtsource-codele-program-remove-vowels-om-sting 18sierz017 C program to elete vowels from a string | Programming Simplified
case "U':
return 15
default:
return @;
y
)
Output of program:
) C\Pragram Files (86\Dev-Cp.,. UHL)
ing to dolote vous
OES Str crieerstacratr tested
string after deleting vowel:
essere beer raea ed
C programming code using pointers
Hincludecstdio.h>
Hincludecstdlib.h>
Hincludecstring.h>
define TRUE 1
define FALSE 0
int check_vowel(char);
nain()
{
char string[1@0], *tenp, *pointer, ch, *start;
printf(“enter a string\n");
gets(string);
tenp = strings
pointer = (char)malloc(190) ;
46 pointer
«
printf(“Unable to allocate menory.\n");
exit (EXIT_FAILURE) ;
y
NULL )
start = pointers
while(*temp)
4
ch = *tenp;
if ( Icheck_vowel (ch) )
“pointer = ch;
pointers;
+
tempi
y
“pointer = "\e";
pointer = start;
tpn programmingsimplifed.comtsource-codele-program-remove-vowels-on-sting 218sierz017 program to elete vowels from a sting | Programming Simplified
strepy(string, pointer); /* If you wish to convert original string */
#ree(pointer);
string);
printf("string after renoving vowel is \"%s\"\r
return @5
)
Ant check_vowel(char a)
t
if (ad= ‘At 8b ac 'Z")
af ( fa fla
return TRUE;
return FALSE;
tpn programmingsinplifed.comtsource-codele-program-remove-vowels-on-sting
ais