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;
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[]
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.