Regarding String Compression Program

I have tried to solve the program string compression but it is not working can you tell me how to correct it?https://ide.codingblocks.com/s/562590

hello @sarthak_singhal

u have misunderstood the problem, here u have to compress only consecutive same character.
for example->
aaaabba will be compressed as
a4b2a1

Approach->

  1. Take the first character of the present string and store it in say ‘ch’. Start iterating over the string and obtain the count of this character occurring consecutively from this point.
  2. Obtain the answer for remaining string recursively.
  3. Return ch+countOfCh+recursiveResult .

https://ide.codingblocks.com/s/571048 I have made the changes but still I can’t get right answer. Can you help me in correcting my program

not every time u have to create space. sometime u may have to reduce the space as well.
ex->
aaabb
in this case after compressing a3bb u need to shift other charatcer to left .

whereas for case lile this abb
to compress a u need to shift remaining characters to right
a1bb .

use c++ string …
check this