Even though s1.size() - s2.size()
is under 0, the for loop does not finish...
I hope someone gives me the idea how this occurs.
input:
abc
abcd
#include <bits/stdc++.h>
using namespace std;
signed main()
{
string s1, s2;
getline(cin, s1), getline(cin, s2);
cout << s1.size() << endl; // 2
cout << s2.size() << endl; // 3
for (int i = 0; i <= s1.size() - s2.size(); i++)
{
cout << "infinite loop" << endl;
}
return 0;
}