My code is not correct ..could you please correct my code and write my errors in comments

question:
string compression

answer:

helloo @aarijrab there were errors i have corrected your code and now its giving correct output .


the major issue was you were treating array as sequence of characters and with that also you were doing wrong .
i hope i have cleared your doubt .
Happy Learning !!

Hey @aarijrab how can I help you.

i have a doubt…will we not check boundary conditio here…that if string is just “b” …then how will loop calculate…and one more doubt- why count[str[i]] is not working for calculating…your approach is easy but why my approach is faling

Here I updated 2 statemets n your code to remove compilation errors https://ide.codingblocks.com/s/326988
Now try your code for bbbabbb ,you will understand why its wrong.

And the code that @tusharaggarwal272 in it you dont hve to check if string only contains only char b or something, it will work for all the cases

Because if only char b then it will print b (0+1) =b1

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.