Firstly, you may like to note that you mentioned using a vector of characters, but your code uses C++ strings, which is probably what you really meant to say?
Also, you need to lean to break up your program into 'jobs' ... and each job can be called by coding a function to do that specific job, then calling the function to execute that job at the appropriate place in the logic flow of your program.
Using descriptive function names, will help to self-document the logic flow of your program.
The following example may help you to see this:
// compareStrings.cpp // // 2017-10-07 //
#include <iostream>
#include <sstream>
#include <string>
#include <cctype>
bool match( const std::string& a, const std::string& b, unsigned numChars )
{
if( a.size() >= numChars && b.size() >= numChars )
{
for( unsigned i = 0; i < numChars; ++ i )
{
if( a[i] != b[i] ) return false;
}
// if reach here ...
return true;
}
// if reach here ...
std::cout << "Either '" << a << "'and/or '"
<< b << "' had less than " << numChars << " characters, so ...\n";
return false;
}
std::string takeInString( const std::string& msg )
{
std::cout << msg;
std::string line;
getline( std::cin, line );
return line;
}
char takeInChr( const std::string& msg )
{
std::string reply = takeInString( msg );
if( reply.size() )
return reply[0];
// else ...
return 0;
}
bool more( const std::string& text )
{
if( tolower( takeInChr( "More " …