C Program to delete vowels from a string


In this program, You will learn how to delete the occurrences of vowels from a string in c.


String: Xiith

After remove vowels: Xth


Example: How to delete vowels from a string in c

Run it Now
#include<stdio.h>
#include<string.h>

int main() {

   char str[100], temp[100];
   int i = 0, j = 0;

   printf("Enter any String :");
   fgets(str, 100, stdin);

   while (str[i] != '\0') {
       if (str[i] != 'a' && str[i] != 'e' &&
               str[i] != 'i' && str[i] != 'o' &&
               str[i] != 'u' && str[i] != 'A' &&
               str[i] != 'E' && str[i] != 'I' &&
               str[i] != 'O' && str[i] != 'U') {

           temp[j++] = str[i];
       }
       i++;
   }
   str[j] = '\0';
   strcpy(str, temp);
   printf("\nString without Vowels is :%s", str);

   return 0;
}

Output:

Enter any String :pointer
String without Vowels is :pntr