String compression, 2 test cases failing ,need hint

#include
using namespace std;
int main() {

string s;
getline(cin,s);
int k=s.length();
int count[256]={0};

for(int i=0;i<k;++i)
{ count[s[i]]++; }
int h=0;
while(count[s[h]]!=0)
{ cout<<s[h]<<count[s[h]];
h=h+count[s[h]];
}
return 0;
}

Hey @rohansrivastav
Please re-read the question u have to compress consecutive chars
For
aabbaaa
your output should be
a2b2a3

ill try this but its not written in the question

its just written that perform simple string compression

see explanation of the example

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.