首页 > 解决方案 > 写入地址 0x0090000 时发生访问冲突

问题描述

尝试打开此代码时出现此错误:Struct.exe 中的地址 0x7B7EE63C (ucrtbased.dll) 引发异常:0xC0000005:写入地址 0x0090000 时发生访问冲突

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

struct automob {
    char marka[15];
    int year, price;
};

struct automob1 {
    char marka1[15];
    int year1, price1;
};


int main()
{
    FILE *file, *file1;
    struct automob a[5];

    fopen_s(&file,"file.txt", "w");

    for (int i = 0; i < 5; i++)
    {
        printf("Enter the mark: ");
        scanf_s("%s %d %d", a[i].marka, a[i].year, a[i].price);
        fprintf(file, "%s %d %d \n", a[i].marka, a[i].year, a[i].price);
    }

    fclose(file);

    fopen_s(&file, "C:\\Users\\tiama\\source\\repos\\Struct\Struct\\file.txt", "w");
    printf("Firm bla bla: \n");


    return 0;
}

标签: c

解决方案


推荐阅读