title: Why am I getting segmentation fault in my following C code?
body: <p>This is a problem from spoj named prime1. The code seems to be correct to me. This even runs and produces desirable results on ideone.com but spoj gives me a runtime error, saying this is a segmentation fault. I can't find any memory leaks, no buffer overflow, etc. Please help me find the segmentation fault.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  unsigned int arr[32200];
  
  int prime()
  {
      unsigned int i,j,k=2;
      int flag;
      arr[0]=2;
      arr[1]=3;
      for (i=5;i&lt;32200;i+=2)
      {
           flag=0;
           for(j=3;j&lt;i;j+=2)
           {
               if(i%j==0)
               {
                   flag=1;
                   break;
               }
           }
           if (flag==0)
           {
               arr[k++]=i;
           }
       }
  return 0;
  }
  
  int main()
  {
      int t;
      unsigned int a,b,i,m;
      scanf("%d",&amp;t);
      prime();
      while(t--)
      {
           scanf("%u%u",&amp;a,&amp;b);
           for(i=0;;i++)
           {
               if (arr[i]&gt;=a)
               {
                   m=i;
                   break;
               }
           }
           while(arr[m]&lt;=b)
           {
               printf("%u\n",arr[m]);
               m++;
           }
           printf("\n");
      }
      return 0;
  }
  </code></pre>