I am unable to determine the cause of the error .
declaring function prototype as :
long long int myfunc(long long int,long long int);
A global array has been declared as :
long long int a[50000];
calling function myfunc() by copying parameters start and end like :
num=myfunc(start,end);
Function Definition :
long long int myfunc(long long int start,long long int end)
{
long long int x=0;
int i=0;
if((start<0)||(start>10000)||(end>10001)||(end<0))
return 0;
for(i=start;i<=end;i++)
{
x = x+ a[i];
}
return x;
}
By Commenting out the loop in the function I am able to get WC as result but in all other cases its Runtime Error ( SIGSEGV) . The above function is the only place where the array is being accessed. Program working fine on my system ( tested with boundry conditions) !
↧
Can't figure out the reason for getting a SiGSEGV run time error
↧