这个用fopen_s怎么改

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/885762752176148.png
这个地方一直报错,要怎么改?

回答:VS里面fopen_s的使用,可以参考这篇文章:https://blog.csdn.net/qq_45919489/article/details/104222423

这里是一段截取代码

void writeandexit()
{
    FILE* fp;
    errno_t err = fopen_s(&fp, "D:/student.csv", "w+");

    if (err != 0)
    {
        printf("文件打开失败,写入失败,程序退出\n");
        return;
    }
    else
    {
        fprintf(fp, "学生学号,姓名,性别(男生1,女生2),体重指数,肺活量,引体向上或仰卧起坐数\n");

        int i;
        for (i = 0; i < MAX; i++)
        {
            if (strcmp(stu[i].studentID, "") != 0)
            {
                fprintf(fp, "%s,%s,%d,%lf,%d,%d\n", stu[i].studentID, stu[i].name, stu[i].sex, stu[i].BMI, stu[i].vital, stu[i].yin_yang);
            }
        }
        fclose(fp);
        printf("文件写入成功,程序退出\n");
    }
}