c语言 链表快速排列 报错

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
typedef struct Student          //学生成绩结构体
{
    char name[50];
    int xuehao;
    double score[N];
    int ranking;
}student;

typedef struct Node  //链表结点 
{
    student stu;
    struct Node* next;
}Node, * PointNode;


void Quicksort(PointNode& tf, PointNode& p)//tf是链表头结点 p是链表尾结点
{
    PointNode i = tf;
    PointNode n=tf;
    PointNode m=tf;
    PointNode j = p;
    
    
    student t, temp;
    if (i == j)
        return;
    temp = i->stu;
    while (i != j)
    {
        while (j->stu.ranking >= temp.ranking && i != j)
        {
            for (n = tf; n != j; n = n->next)
                m = n;
            j = m;
        }
    
    while (i->stu.ranking <= temp.ranking && i != j)
        {
            i = i->next;
        }
        if (i != j)
        {
            t = i->stu;
            i->stu = j->stu;
            j->stu = t;
        }
    }
    tf->stu = i->stu;
    i->stu = temp;
    for (n = tf; n != i; n = n->next)
        m = n;

    Quicksort(tf, m);
    Quicksort(i->next, p);
}

运行结果及报错内容

img

我的解答思路和尝试过的方法
我想要达到的结果

你要加个判断 n!=NULL

        for (n = tf; n!=NULL && n != j; n = n->next)
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632