String compression

#include
#include
using namespace std;
int main() {
char str[100];
cin.getline(str,100);
int n=strlen(str);
int i=0;
while(i<n){
int y=i;
char ch=str[y];
for(int k=0;k<n;k++){
if(str[y]==str[k]){
i++;
}
}
i–;
//cout<<i;
//cout<<i<<endl;

    char c=str[i];
	//cout<<c<<endl;
	int count=0;
	for(int j=0;j<n;j++){
		if(c==str[j]){
			count++;
		}
	}
      cout<<c<<count;
	  i++;

}
return 0;
}
what may be the error .some test case failed