String compression

i am unable to pass one test case.

Take as input S, a string. Write a function that does basic string compression. Print the value returned. E.g. for input “aaabbccds” print out a3b2c2d1s1.

Input Format
A single String S

Constraints
1 < = length of String < = 100

Output Format
The compressed String.

Sample Input
aaabbccds
Sample Output
a3b2c2d1s1
Explanation
In the given sample test case ‘a’ is repeated 3 times consecutively, ‘b’ is repeated twice, ‘c’ is repeated twice and 'd and ‘s’ occurred only once.

#include
using namespace std;
string shorts(string s){
int i=0,count=0;
char ch;
string comp="";
while(i<s.length()){
ch=s[i];
count=1;
i++;
while(s[i]==ch){
count++;
i++;
}
comp+=ch;
comp+=char(count+48);
}
return comp;
}
int main() {
string s;
cin>>s;
cout<<shorts(s);
return 0;
}