(ntdll.dll) (泊车管理系统.exe 中)处有未经处理的异常: 0xC0000005: 写入位置 0x0041BE88 时发生访问冲突。

img


struct Password

struct Password
{
    int no;
    char user[20];     //用户名(20个字符内)
    char password[20]; //密码(20个字符内)
};

int creatuser(Password *Password)
{
    //int n;
    FILE *fp=fopen_s(&fp,"D:\\user.txt", "w");
    if (fp!=NULL) 
    {
        fwrite(Password, sizePassword,1,fp);
        fclose(fp);
        return 1;
    }
    else
    {
        printf("打开文件失败\n");
        exit(0);
    }
}
fwrite(Password, sizePassword,1,fp);
改为
fwrite(Password, sizeof(struct Password),1,fp);