Need help with segmentation fault
so,here´s my problem:i have a function that should order an array by the size of the words that compose it.The array is declared as **text,and has strings in each position.The problem is that i´m having a segmentation fault and cant solve it.i post here the fucntion so that someone can help me:
Code:
void ordena_histograma(char **texto,int num,int i)
{
int n=0,u=0,j;
char *temp;
if(i == (num-1))
;
else
{
n=strlen(texto[i]);
u=strlen(texto[i+1]);
if(n<=u)
ordena_histograma(texto, num, i+1);
else
{
temp=(char *)malloc (n);
*temp=*(texto[i]);
texto[i]=texto[i+1];
texto[i+1]=temp;
ordena_histograma(texto,num,i+1);
}
}
}