i tried counting sort and complied in "http://www.tutorialspoint.com/compile_c_online.php" and it ran perfectly but when i tried to compile in "http://codepad.org" ,it said segmentation fault.i tried using gdb but it didnot show any error. here is the code can anyone find the line causing it.
#include<stdio.h>
int main(void)
{
long long int t;
int i=0,j,max,min,temp,pos;
scanf("%lld",&t);//enter total numbers to be sorted
long long int a[t];
while(i<t)
{
scanf("%lld",&a[i]);
if(i==0) max=min=a[i];
else
{
if(a[i]>=max) max=a[i];
if(a[i]<min) min=a[i];
}
++i;
}
temp=(max-min+1);
long long int b[temp];
for(i=0;i<t;i++)
for(j=min;j<=max;j++)
{
if(i==0) b[j-min]=0;
if(a[i]==j) ++b[j-min];
}
for(i=0;i<temp;i++) if(i!=0) b[i]=b[i]+b[i-1];
long long int c[t];
for(i=0;i<t;i++)
{
for(j=0;j<temp;j++)
{
if(a[i]==(j+min))
{
pos=(b[j]-1);
c[pos]=j+min;
--b[j];
}
}
}
for(j=0;j<t;j++) printf("%lld\n",c[j]);
return(0);
}