does anyone have any ideas I'm stuck on comparing the two strings..
Basically I have one string and a vector of characters.
I have sorted both in ascending order. basically I need to output the string if all of the characters in it match some or all of the characters from the vector.
eg
vector characters is airport
string is
airport
output airport
or vector characters is airport
string is air
output air
I know it is probaby something simple but I cant work out how to do it?
I have written up a code and am erasing the character from the string when ther is a match but the thing I am finding is that I know I have it wrong but I dont know how to fix it... can someone help??
int sum = 0;
sum = c.length(); // this is the string from the txt file
for (int h = 0; h < c.length(); h++)
{
if (c.at(h) == otherLetters.at (h))
{
sum--;
c.erase(h, 1);
// cout << c1 << endl; //this is the string when it isnt sorted
// cout << c << endl; //this is the sorted string
// cout << otherLetters.at (h) << endl; //this is the sorted vector
// if (sum == 0) // sum never is 0.. I have made an error somewhere in the above loop but I'm stuck..
// {
// cout << "this is the output " << c1 << endl; //cant even get to this point.
// }
Basically I have one string and a vector of characters.
I have sorted both in ascending order. basically I need to output the string if all of the characters in it match some or all of the characters from the vector.
eg
vector characters is airport
string is
airport
output airport
or vector characters is airport
string is air
output air
I know it is probaby something simple but I cant work out how to do it?
I have written up a code and am erasing the character from the string when ther is a match but the thing I am finding is that I know I have it wrong but I dont know how to fix it... can someone help??
int sum = 0;
sum = c.length(); // this is the string from the txt file
for (int h = 0; h < c.length(); h++)
{
if (c.at(h) == otherLetters.at (h))
{
sum--;
c.erase(h, 1);
// cout << c1 << endl; //this is the string when it isnt sorted
// cout << c << endl; //this is the sorted string
// cout << otherLetters.at (h) << endl; //this is the sorted vector
// if (sum == 0) // sum never is 0.. I have made an error somewhere in the above loop but I'm stuck..
// {
// cout << "this is the output " << c1 << endl; //cant even get to this point.
// }
Comment