如何修复“在0x00007FF9460FC231(ucrtbased.dll)引发异常”

时间:2019-06-16 13:00:28

标签: c++

我正在使用C ++进行编码,并且想解决一个问题“在local_project.exe中的0x00007FF9351FC231(ucrtbased.dll)引发异常:0xC0000005:访问冲突读取位置0x0000000000000000。”

我正在使用Visual Studio 2017。 输出sign()值后发生错误。 我尝试将数据类型'string'更改为'char',但这没有用。而且我将部分迭代器作为例外,但是发生了相同的问题。

#include <iostream>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <list>

using namespace std;

//sign()
string sign()
{
    string id;
    string password;
    string name;
    string dpt;

    list<string> sign_data;
    list<string>::iterator s_iterator;

    cout << ">> Sign_up <<" << endl;
    cin.ignore(1, '\n');
    cout << "ID: ";
    getline(cin, id);
    cout << "Password: ";
    getline(cin, password);
    cout << "Name: ";
    getline(cin, name);
    cout << "Department: ";
    getline(cin, dpt);

    sign_data.push_back(id);
    sign_data.push_back(password);
    sign_data.push_back(name);
    sign_data.push_back(dpt);

    for (s_iterator = sign_data.begin(); s_iterator != sign_data.end(); ++s_iterator) {
        cout << *s_iterator << endl;
    }

    return 0;
}

int main()
{
    int num;
    site_member Member;

    do {
        cout << ">> Menu <<" << endl;
        cout << "1.Login\n"
             << "2.Sign_up\n"
             << "3.Write\n"
             << "4.edit\n"
             << "5.exit\n" << endl;
        cout << "Number:";
        cin >> num;

        if (num == 1) {
            Member.login();
        }
        else if (num == 2) {
            sign();
        }
        else if (num == 3) {
            Member.write();
            //main();
        }
        else if (num == 5) {
            return 0;
        }
        else {
            cout << "Wrong number. Please re-enter:" << endl;
            main();
        };
    } while (num != 5);

    return 0;
}

0 个答案:

没有答案