Form biggest number

Whats wrong with this code?
#include
#include
using namespace std;

bool myCompare(string a, string b){
string ab = a.append(b);
string ba = b.append(a);

return ab > ba;

}

int main(){
int n, t;
cin>>t;
cin>>n;

while(t>0){
	  string a[n];

for(int i = 0; i<n; i++){
    cin>>a[i];
}

sort(a, a+n, myCompare);
for(int i = 0; i<n; i++){
    cout<<a[i];
}
cout<<endl;
t--;
}

return 0;

}

Hello @arjun.12narang what is the problem that you are facing?

This code is failing every testcase.

@arjun.12narang https://ide.codingblocks.com/s/388113
corrected code:
HappyLearning!!

Even if the code takes input ‘n’ for only once, then why cant we use it again and again as the input given to ‘n’ remains constant.

we have to take input for every test case to know about the number of strings.

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.