The code works fine on test cases but shows an error when I submit non of the test cases give the right output

When I give any random test case to the code for the Problem " Form Biggest Number" as custom input, the code works perfectly but when I submit the code, the first test case gives the wrong answer while the other test cases give “Run Error”.

Here is my code: https://ide.codingblocks.com/s/291782

Please help!

hello @Yash5646
run ur code for this test case ->
1
2
21 2
ur output ->
212
correct output ->
221

to rectify it
comparator should be
return a+b > b+a

The first Test Case is successful now but the other test case still give a Run Error

dont use getline and strtok.
simply use loop and read n string.
for(int i=0;i<n;i++)
cin>>str[i];

@aman212yadav
Thanks ! The code worked perfectly. But what exactly was causing this error ?

ur comparator was not correct.

getlin will read a line .
but in some test files , numbers are present in different rows

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.