runtime error SIGSEGV

I am getting a runtime error(Runtime Error(SIGSEGV))for this code(given below).
It is running fine in the site’s compiler but it shows error when I submit the code as an answer.
The question is http://www.codechef.com/problems/DDISH/
It would be a great help if someone could guide me on this.
code:

#include<stdio.h>
int l[2000],r[2000],p[2000];

int main()

{

int t,i,j,d,c;int a[10],ctr;

ctr,t=0;

scanf("%d",&t);

scanf("\n");

for(i=1;i<=t;i++)

scanf("%d %d",&r[i],&l[i]);

while(ctr!=t)

{

ctr++;

for(j=0;j<10;j++)

{

a[j]=0;

}

for(i=r[ctr];i<=l[ctr];i++)

{
c=i;

for(j=0;j<10;j++)

{

 a[j]=0;

}

    while(c!=0)

    {

	d=c%10;

	a[d]++;

	c=c/10;

    }

   if((a[0]>1)||(a[1]>1)||(a[2]>1)||(a[3]>1)||(a[4]>1)||(a[5]>1)||(a[6]>1)||(a[7]>1)||(a[8]>1)||(a[9]>1))

   {continue;}


   else

   {p[ctr]++;}

}


printf("%d\n",p[ctr]);

}

return 0;

}

I have tried the suggestions but it didn’t work .

I am pretty sure, ctr,l[2000],r[2000],p[2000]=0; doesn’t work the way you think.

Also, l, r and p are arrays of size 2000, which are indexed from 0 to 1999. trying to access l[2000], r[2000], p[2000] can all lead to SIGSEGV.

what about nzec error what are the reasons for it i mean possible reasons for it

“for(i=1;i<=t;i++)”, your t isn’t initialized, so that there is a trash.
Please, initialize ALL your variables! int t = 0, etc;

What is a type of your arrays? if they are int then initialize them like l[200] = {0,};

but I am reading the value of t and then using it in the loop.
If it was a problem , it didn’t give me any error when I compiled using the sites compiler .
It just showed an error after I submitted it. I appreciate your help and I will definitely try it. Thank You.

Ok I will initialize all of them separately using a loop.
But isn’t there any easier way to initialize it ?

For this particular program, you are initializing all the array elements to 0 ONLY ONCE. In this case, the following bit of info will help you:

All global variables/arrays are automatically initialized to 0.

So, your array is initialized to 0 automatically. Need not worry about that.
If you, however, need to re-initialize them repeatedly in a loop (for some other problem, maybe), then you would need to do that in a loop (as your program currently does.)

@grvana

NZEC stands for Non-Zero Exit Code. You must have already noticed a “return 0” at the end of many programs. That particular return value means, the program finished execution without any problems, and that it can now exit successfully. (Any other return value will be interpreted as some error that occurred during runtime.)

There are many reasons for getting runtime errors. Not having an explicit ‘return 0’ is one reason. Calling some library method with illegal arguments, which might in turn, call exit(xx); upon sensing illegal arguments, where xx in a non-zero value, is another.