Why my code is getting dumped?

#include
#include
using namespace std;
bool compare(string a,string b)
{
int n=a.length();
int m=b.length();
int mn=min(n,m);
for(int i=0;i<mn;i++)
{
if(a[i]!=b[i])
return a<b;
}
return n>m;
}
void display(string a[],int n)
{
for(int i=0;i<n;i++)
cout<<a[i]<<endl;
}
int main()
{
int n;
cin>>n;
string* ptr=new string[n];
for(int i=0;i<n;i++)
cin>>ptr[i];
sort(ptr,ptr+n,compare);
display(ptr,n);
return 0;
}

@namangarg31,
Please use Coding Blocks IDE to share your codes, don’t just copy/paste here.
Also, I don’t think you know how string class works. So, in your code, replace string by char.