有人能告诉我,最后的while函数为什么会陷入死循环吗?
#include <iostream>
#include <string>
using namespace std;
string a,s;
int cnt = 0,pos;
int main()
{
getline(cin, a);
getline(cin , s);
for (int i = 0; i < a.length(); i++)
{
if (a[i]>=65 && a[i] <= 90)
{
a[i] += 32;
}
}
for (int i = 0; i < s.length(); i++)
{
if (s[i] >=65 && s[i] <= 90)
{
s[i] += 32;
}
}
int f = s.find(a,0);
if (f >= 0)
{
cnt++;
pos = f;
}
else
{
cout << "-1" << endl;
return 0;
}
int n = f;
while (pos >=0)
{
pos =s.find(a, pos);
cnt++;
}
cout << cnt - 1 << " " << f << endl;
return 0;
}