String compression problem


Help me to correct this code.

Hey @Yukta In this question you need to Count the number of occurance of each character in given strings and print one character follow by number of occurance, and your current code doesn’t do that, please refer to the given code snippet for correct solution

for(int i=0;s[i]!='\0';i++){
    int count =1;
    for(int j=i+1;s[j]!='\0';j++){ 
		if(s[i]==s[j])
			count++;
		else   
			break;  
    }
    cout<<s[i]<<count;  
    i += count-1;  
}

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.