Switch to full style
For C/C++ coders discussions and solutions
Post a reply

Remove all the vowels from a string

Thu Nov 15, 2012 6:44 pm

This is the instructions for the program I have to write:
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str = "There", then after removing all the vowels, str = "Thr". After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.

With that being said, this is the program I have written. I am not sure if it is correct or not though and I was wanting to seek help on it. Any pointers would be greatly appreciated.

Code:
int main()
{
   string str;
   void removeVowels(string str);   
   
   cout << "Enter a string: ";
   cin >> str;
   cout << endl;

   cout << "The new string is: " << removeVowels << endl;
   
   cout << "\nThe stringafter the function is: " << str << endl;
   return 0;
}

bool isVowel(char ch)
{
      if ((ch=='A')||(ch=='E')||(ch=='I')||(ch=='O')||(ch=='U')
         ||(ch=='a')||(ch=='e')||(ch=='i')||(ch=='o')||(ch=='u'))
   {
      cout << isVowel << endl;
      return true;
   }
      else
   {
      return false;
   }
   {
      cout << str.substr(isVowel) << endl;
   }
   return 0;
}




Post a reply
  Related Posts  to : Remove all the vowels from a string
 How to remove special characters from a string in Java?     -  
 Splitting a String Based on a Found String     -  
 recursive string reversal- reverse string     -  
 check if string ends with specific sub-string in php     -  
 check if string start with a specific sub-string in PHP     -  
 Remove Indentation     -  
 remove page title     -  
 Add and Remove CSS classes to html tag dynamically     -  
 Remove ordered list numbers     -  
 Remove a portion of the array and replace it with something     -  

Topic Tags

C++ Strings