String str, substr
Cout & lt& lt Please enter a string: ";
CIN & gt; & gtstr
Cout < < "Please enter the character field to be counted:";
CIN & gt; & gtsubstr
int num = 0;
string::size _ type pos = 0;
while((pos = str.find(substr,pos))! = string::NPO)
{
num++;
++ pos;
}
Cout & lt& lt "The number of occurrences of the searched character segment is:"
Returns 0;
}//Enter a segment, and then enter a short segment to get the number of occurrences of the short segment.
That's it, I hope the landlord can understand ~