segmentation fault...:(
some one help me pls..
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char a[50];
char *x[10];
int i,j,n;
char *temp;
printf("enter the no of strings:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the string:");
scanf("%s",a);
x[i]=(char *)malloc((strlen(a)+1)*sizeof(char));
if(x[i]==NULL){
printf("malloc not done");
exit(1);}
strcpy(x[i],a);
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i;j++)
{
if(strcmp(x[j],x[j+1])>0)
{
strcpy(temp,x[j]);
strcpy(x[j],x[j+1]);
strcpy(x[j+1],temp);
}
}
}
return 0;
}