String compression

Getting Wrong answer message while I have chaecked over all test cases. here is my code pls check it out.

#include
#include
using namespace std;
void compression(string s, int l, char unique[],int ul)
{
int count=0;
for(int i=0;i<ul;i++)
{
count =0;
for(int j=0;j<l;j++)
{
if(unique[i]==s[j])
count++;
}
cout<<unique[i]<<count;
}
}
int main() {
string s;
cin>>s;
int l = s.length();
char unique[30];
int index=0,maxx=0;
for(int i=0;i<l;i++)
{
int j;
for(j=0;j<i;j++)
{
if(s[i]==s[j])
{
break;
}
}
if(j == i)
unique[index++] = s[i];
}
unique[index] = ‘\0’;
compression(s,l,unique,index);
return 0;
}

Hello @Debugger,

From the next time, share your code using Online Coding Blocks IDE.
The way you have shared it is introducing many syntax errors to it.
Steps:

  1. Paste your code on https://ide.codingblocks.com/
  2. Save it there.
  3. Share the URL generated.

Now coming back to your question:

  1. The size of the unique array is less.
    Modification:
    char unique[100];

  2. You have understood the question incorrectly.
    It is failing for the test cases like:
    aaabbaacc
    Expected Output:
    a3b2a2c2
    Your Output:
    a5b2c2

Hope, this would help.
Give a like if you are satisfied.