Why this code passes only two test cases

void count(char ch[])
{
int i=0;
int cx[26]={0};
while(ch[i]!=’\0’)
{
cx[ch[i]-‘a’]++;
i++;
}
i=0;
char visited[26]={0};
while(ch[i]!=’\0’)
{
if(visited[ch[i]-‘a’]==0)
{
cout<<ch[i]<<cx[ch[i]-‘a’];
visited[ch[i]-‘a’]=1;
}

	i++;
}

}
int main()
{
char ch[100];
cin>>ch;

count(ch);

}

Consider a test case:
sskkkkkkwaerrtss

Expected Output:
s2k6w1a1e1r2t1s2

Your Output:
s4k6w1a1e1r2t1

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.