String compression

#include
#include<bits/stdc++.h>
using namespace std;
string pall(string a)
{
string c;
int len=a.length();
char b[256];
for(int i=0;i<256;i++)
{
b[i]=‘0’;

}
for(int i=0;i<len;i++)
{

b[a[i]]++;

}
for(int i=0;i<len;i++)
{ if(b[a[i]]!=‘0’)
{c=c+a[i]+b[a[i]];
b[a[i]]=‘0’;}

}
return c;
}

int main()
{
string a;
cin>>a;
cout<<pall(a);

}
it fails for two test case why??

Hi @sdevesh29,
can u pls resend ur code using ide.codingblocks.com.
While directly sharing ur code on discuss forum, some character get changed.
Sorry for d inconvenience caused.

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.