Im trying to create a function to remove vowels from a string with spaces (not a cstring).
I need to pass the string into the function and have it add every consonant to another string that will return the string without the vowels. I need to keep the original string that has both the vowels and the consonants. Im stuck on how to check and add a consonant to the returning string.
ex: input: Alexander Hamilton
output: lxndr Hmltn
#include <iostream>
#include <string>
using namespace std;
string removeVowels(string input, int size);
int main()
{
string input;
string vowlessFinal;
getline(cin, input);
cout << input;
vowlessFinal = removeVowels(input, 20);
cout << vowlessFinal;
}
string removeVowels(string input, int size) {
string vowlessFinal;
int j = 0;
for (int i = 0; i < input.size(); i++) {
//i have just 'a' below but i need to have the rest (including caps)
if (input.at(i) != 'a') {
vowlessGuess.at(j) = input.at(i);
j++;
}
}
return vowlessFinal;
}