#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int count = 0;
vector<string> v;
string resp;
cin >> resp;
v.push_back(resp);
for(int i = 0; i < v.size(); i++){
if(find(v.begin(), v.end(), "xy") != v.end()){
count++;
}
cout << count << endl;
}
return 0;
}
I want to find the character "xy" in the string for multiple test cases. For input xy, my count value outputs correctly as 1.
But for the input xyxxy instead of 2 it gives the value as 0 It is only finding the value once but i want to check the count of xy in whole string
I tried to use the substring function as well but it failed to work