RUNTIME ERROR IN ANARC

Why is this code giving segmentation fault? The stack has been handled properly.

#include<stdio.h>
#include<string.h>

char pop(char * );
void push(char *,char);
int change(char *,int);
int s;

int main(){

    int x,op,cl,i,k,c=1;
    char arr[2000],arr1[2000],r;

    while(5){
             scanf("%s",&arr);

             if(arr[0]=='-')
             break;
             if(arr[0]=='\0'){
             printf("%d. 0",c);
             break;
             }
             x=0;
               i=op=cl=k=0;
               s=-1;
              while(x<strlen(arr)){
                                   if(arr[x]=='{'){
                                   push(arr1,'{');

                                   }

                                   if(arr[x]=='}'){
                                   r=  pop(arr1);



                                   if(r=='1'){
                                   x= change(arr,x);

                                   i++;

                                   }
                                   }
                                   x++;
                                   }
                              while(5)
                              {
                                         r=pop(arr1);

                                         if(r=='1')
                                         break;
                                         k++;

                                         }
               //if(op!=cl)
               //k=op>cl?((op-cl)/2):((cl-op)/2);
               //else
               //k=i;
                if(k%2==0)
               printf("%d. %d\n",c,i+(k/2));
               else
               printf("%d. %d\n",c,i+k);
             c++;
               }

               return 0;
               }

  char pop(char *arr1){
       if(s>=0)
       return arr1[s--];
       else
       return '1';
       }

  void push(char *arr1,char t){
       arr1[++s]=t;
       }

int change(char *arr,int x){
    arr[x--]='{';
    return x;
}

Actually,you are accessing memory arr[2000] and arr1[2000] which can only be done when you declare both of them as ** char arr[2001],arr[2001]; **.Hope this solves your problem.