String compression in c++


why the 2nd and 4th testcase was wrong .and what are these 4 testcases for ,all for various inouts?

@Chandra123
Your code works on several assumptions that are not there.
You are printing the output for all characters from a to z. You are only required to print the output for the characters that are there in the string.
Input :
aabbb

Expected Output :
a2b3

Your Output :
a2b3c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0

Even if you correct this , there are still some problems with your code.

Your code prints output in sorted order. It is never asked or demanded in the problem.
Input :
bbaa

Expected Output :
b2a2

Your Output :
a2b2

Secondly , your code merges different occurrences of same character together , even those which are not consecutive.
Input :
aabbaaa

Expected Output :
a2b2a3

Your Output :
a5b2