Question: in this code when i input this line - this IS a TEST the code outputs - invalid input. how to fix that? vector plainText()
in this code when i input this line -
this IS a TEST
the code outputs - invalid input. how to fix that?
vector
{
string textMessage = "";
vector
while (true)
{
cout << "Enter a plain text to be encoded" << endl;
getline(cin, textMessage);
bool validInput = true;
for (int i = 0; i < textMessage.length(); i++)
{
if (!isalpha(textMessage[i]))
{
validInput = false;
cout << "Invalid Input" << endl;
break;
}
}
if (validInput)
{
for (int i = 0; i < textMessage.length(); i++)
{
plainTextVector.push_back(textMessage[i]);
}
return plainTextVector;
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
