SIGABRT ERROR

I wrote a code for a solution of a codechef problem. When I run the code in DEV C++ it runs smoothly without any error. But when I submit it I get a RUN TIME ERROR(SIGABRT). Please help me with the code. I am not understanding the reason behind the problem. I searched a lot about SIGABRT but what I got is code specific reason and not a general reason.Thanks in advance. Following is the full code I submitted.

#include <iostream>
using namespace std;

void selsort(long long *ssum,long long len) //code for sorting in asc order
{
long long low;
for(long long i=0;i<len;i++)
{

low = ssum[i];
long long pos=i;
for(int j=i+1;j<len;j++)
{

if(ssum[j]<low)
{
low = ssum[j];
pos = j;

}

}


ssum[pos] = ssum[i];
ssum[i] = low;
}


}

int main()
{

int t,k,q;
cin>>t;

for(int i=0;i<t;i++)
{
cin>>k;
cin>>q;

long long *mot=NULL,*sat=NULL;
mot = new long long [k];
sat = new long long [k];
long long *sum = new long long[k*k];
int qth;
long long b=0;

for(int j=0;j<k;j++)
{
cin>>mot[j];

}

for(int j=0;j<k;j++)
{
cin>>sat[j];

}

for(int j=0;j<k;j++)
{
for(int a=0;a<k;a++)
{
sum[b] = mot[a]+sat[j];
b++;
}
}

selsort(sum,k*k);


for(int j=0;j<q;j++)
{
cout<<"\n";
cin>>qth;
cout<<"\n"<<sum[qth-1];
}

delete sum,mot,sat;
}

return 0;
}
Last edited on
delete sum,mot,sat; warning: right operand of comma operator has no effect [-Wunused-value]
Also, you've allocated with new[], so you must deallocate with delete[]

┬┐care to describe the assignment?
http://www.codechef.com/problems/LOWSUM/

this is the problem

and I edited

delete [] sum;
delete [] mot;
delete [] sat;

but its still giving the same error.

Runtime Error(SIGABRT)

Please help....!!
Please use code tags when posting, to make your code more readable.

Step through your code in a debugger, so that you can see exactly which line it crashes on, and what the state of all the variables are at that point.
Thanks and will surely keep in mind in my next post.

But the problem is in my Dev compiler I am not getting any error. The codechef is generating an error. And hence I am not able to find where I am getting it wrong. Its running and working fine in my dev compiler. The problem may be when the codechef uses large quantities but still I am not getting the problem.

Thank you in advance.
Topic archived. No new replies allowed.