typedef struct mensagem
{
int sender ;
int receiver ;
char *text ;
} *Item ;
typedef struct node
{
Item item ;
struct node *next ;
} *link ;
typedef struct queue
{
link head, tail ;
int size ;
} *Queue ;
void listsorted(Queue list)
{
Queue temp = list ;
int s=temp->size ;
char *sorted ;
int i=0;
sorted = (char*) malloc(sizeof(char));
while ( i < s )
{
strcpy( sorted[i] , list->head->item->text ) ;
list->head = list->head->next ;
i++ ;
}
i=0;
for ( i=0 ; i<s ; i++ )
{
printf("%s\n", sorted[i] ) ;
}
}
I want to sort alphabeticaly a queue, so I thought to copy the strings to an array and qsort that array. But i'm not even managing to make the array with the strings. I get an error on the strcpy . What am I doing wrong?
char **sorted; cause you want to have an array of strings.