Я пытаюсь создать функцию, которая сортирует связанный список, который сортирует список по именам.
struct student
{
char name[50];
int roll_no;
struct student *ptr_next;
}*ptr_this,*ptr_first;/*ptr first points to first pointer */
void SortRecord(void)
{
struct student *out,*in,*temp;
for(out=ptr_first;out!=(struct student*)NULL;out=out->ptr_next)
{
for(in=out->ptr_next;out->ptr_next!=(struct student*)NULL;in=in->ptr_next)
{
if(strcmpi(out->name,in->name)<0)
temp->ptr_next=in->ptr_next;
in->ptr_next=out->ptr_next;
out->ptr_next=temp->ptr_next;/*The program stops at this instant and does not proceed after this line*/
}
}
printf("Records have been successfully sorted.");
Я застрял с двумя вопросами: РЕДАКТИРОВАТЬ: Я понял, чтонам нужно только поменять местами указатели, а не содержимое, но мой код все еще зависает при обмене в указанном выше месте.