I am getting some box as ouput instead pf numerical value....what changes should i do

#include
#include
using namespace std;

int main()
{
string s;
getline(cin,s);
int n=s.length();
int freq[26]={0};
for(int i=0;i<n;i++)
{
int digit=s[i]-‘a’;
freq[digit]++;
}
char cstring[100]={0};
int k=0;
for(int i=0;i<n;i++)
{
int digit=s[i]-‘a’;
if(freq[digit]!=0)
{

		cstring[k]=s[i];
		cstring[k+1]=freq[digit];
		freq[digit]=0;
		k=k+2;
	}
	
}
for(int i=0;cstring[i]!='\0';i++)
{
	cout<<cstring[i];
}

return 0;	
}

hey @angivanshikaangi, please share the code saved in Coding blocks ide as text gets mismatched here.

hey @angivanshikaangi, you are getting these boxes because you are storing int value in char array. Check line number 25.(cstring[k+1]=freq[digit]; ) . Make it cstring[k+1]=freq[digit] + ‘0’;

Moreover you approach is also not correct as it is printing wrong answer when same character occurs after gap.
example
input:
aaabbccbbds

your code’s output:
a3b4c2d1s1

but the expected output is:
a3b2c2b2d1s1

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.