I want to get two strings from user and compare them.
I want to see if the letters from the first string are in same order in second one.
for example we have s1,s2 which are our strings.
because s1 order is the same in s2 I want to say yes
because the order of letters is not the same I want the answer no.
my problem is that I don't know how to compare such strings. oh and the lenght of strings can be anything from 1 to 100.
I tried comparing them but I know I'm doing something wrong.
here is my failed attempt
PS.it doesn't matter how many other characters are between the ltters of s1 in s2. only the order is important
std::string str ("x");
// getting the strings str is another string which I wanted to make
//so I can try to find letters of s1 in s2 and put them in it
//since I wasn't sure I can leave it empty I put a "x" in it
std::string::size_type found = s2.find_first_of(s1);
while (i>=0 )
//the part on top is where my code has a problem if you can help me
//to find a another way or fix this one I'll be really thankfull
//I added the "x" to fist of s1 so it will be like str
if (str.compare(s1) == 0)
std::cout << "YES";
if (str.compare(s1) != 0)
std::cout << "NO";