What is wrong with my code

#include<bits/stdc++.h>
using namespace std;

string dup(string s, string sm, int i, int j)
{
//base case
if(s[i]==’\0’)
{
sm[j]= ‘\0’;
return sm;
}
if(s[i]!= s[i+1])
{
sm[j]=s[i];
return dup(s,sm, i+1,j+1);
}
else if(s[i]== s[i+1])
{
return dup(s,sm,i+1,j);
}
return sm;
}
int main() {
string s;
cin>> s;

string sm;
cout<< dup(s,sm, 0, 0);
return 0;

}

@alankrit.agr99 please share your code by saving it on ide.codingblocks.com

i have saved my code on ide.coding blocks, how do I share it?

@alankrit.agr99 a link is generated after you save the code, share that link.

this is my saved code

@alankrit.agr99 https://ide.codingblocks.com/s/262285

initially length of sm is 0, so you cant access any indices in it. You have to append characters.

Please mark the doubt as resolved in case of no further queries.

please show it by editing my code

@alankrit.agr99 i have edited your code and attached the link above please see.