hi all im trying to write this program that take a char array and outputs a vector string where each string contains one letter more than the previous one however, it should not contain any vowels. Prompt the user for the length of the initial string which must be 1,2 or 3 letters and the length of the final string which must be greater than the initial string length.
Prompt the user for the length of the initial string which must be 1,2 or 3 letters and the length of the final string which must be greater than the initial string length.
What is the [length of the] "initial string"? It isn't cPhrase, is it? Same for "final string". And how can the final string be longer if it's the stripped initial string?
cString.push_back(word-(delim-delim1-delim2-delim3-delim4));
You can't subtract a char from a string. What you are doing is subtracting the integral values of the char variables. What was your goal on that line?
And could you please show how the output should look like, if it worked correctly? Like, an example what's in the vector at the end.
#include <iostream>
#include <vector>
#include <sstream>
usingnamespace std;
int main()
{
string Phrase ="Alex, Mike and Nanzhu are the three TAs for this class.";
const string delim = "aeiou";
vector<string> cString;
string appending_char; // we need this, or the compiler will complain,
// that we want to append a char to a string.
bool is_vowel;
for (int i=0; i<Phrase.size(); ++i) {
is_vowel = false;
for (int j=0; j<delim.size(); ++j) {
if (Phrase[i] == delim.at(j))
is_vowel = true;
}
if (is_vowel == false) {
appending_char = Phrase[i];
cString.push_back(appending_char);
}
}
for(size_t i=0; i<cString.size(); i++)
cout << '"' << cString[i] << "\" ";
return 0;
}