gpt4 book ai didi

打开文件时出现 C++ 错误

转载 作者:太空狗 更新时间:2023-10-29 22:53:41 25 4
gpt4 key购买 nike

<分区>

当我尝试在我的控制台应用程序中打开文件进行读取时,我收到此错误消息:“homework1.exe 中 0x1048766d (msvcp90d.dll) 处出现未处理的异常:0xC0000005:访问冲突写入位置 0x00000000。”当我在我的 macbook 上编译和运行程序时它工作正常但是当我使用 VS 2008 在我的桌面上运行它时它给了我这个错误。

这是我的代码:

int main (void){    //Open 1st file (baseproduct.dat)    ifstream fin;    //fin.open(filename.c_str());    fin.open("baseproduct.dat");    int tries;    tries = 0;    while( fin.bad() )    {        if( tries >= 4 )        {            cout > filename;        fin.open(filename.c_str());        tries++;    }    SodaPop inventory[100];    //read file into array    string strName;    double dblPrice;    int i;    i = 0;    fin >> strName;    while( !fin.eof() )    {        inventory[i].setName(strName);        fin >> dblPrice;        inventory[i].setPrice(dblPrice);        fin >> strName;        i++;    }    fin.close();    cout > filename;    //fin.open(filename.c_str());    fin.open("soldproduct.dat");    tries = 0;    while( fin.bad() )    {        if( tries >= 4 )        {            cout > filename;        fin.open(filename.c_str());        tries++;    }    //read file into array    i = 0;    fin >> strName;    while( !fin.eof() )    {        cout > dblPrice;        inventory[i].setPrice(dblPrice);*/        fin >> strName;        i++;        //1. search array for name        //2. get price (what should happen with it?)        //3. add # sold to quantity    }    fin.close();cout 

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com