I have to write a function that reads a string and outputs only the consonants. example: string: adadad output: ddd
I wrote a program without the function and it works. Now I'm trying to change the program to use the function. As of now my only error is: error writing to program database. Any suggestions???
Thanks in advance!!
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
string Consonants;
string Input;
int Index = 0;
string StripVowels(string Consonants);
int main()
{
//Step01: Declare Memory Locations
//Step02: Initialize Memory Locations
//Step03: Do the Work
//Step03a: Ask for Input
cout << "Please enter text: " << endl << endl;
cin >> Input;
cout << endl;
//Stepo3b: Compare chars
while(Index < Input.size()){
StripVowels(Input);
}
//Step04: Wrap up and Exit
cout << endl;
getch();
return 0;
}
string StripVowels(string Consonants){
if(Consonants.substr(Index,1) == "a")
{return false;
Index++;}
else if(Consonants.substr(Index,1) == "e")
{return false;
Index++;}
else if(Consonants.substr(Index,1) == "i")
{return false;
Index++;}
else if(Consonants.substr(Index,1) == "o")
{return false;
Index++;}
else if(Consonants.substr(Index,1) == "u")
{return false;
Index++;}
else
{return Consonants.substr(Index, 1);
Index++;}
}