-2

私はこれを理解しようとして何時間もここに座っていました。私は同様の問題を見つけることができませんでした (私はそれが行われたと確信していますが)。それでは、私の質問に進みます。これをコンパイルすると、問題ありません。
unsortedList は構造体である Book* であることを付け加えておきます。

string tit = tempBook->title;
string act = tempBook->action;
string aut = tempBook->author;
string sub = tempBook->subject;
char* tm = tempBook->time;

unsortedList[unsortedArrayLength].title;
unsortedList[unsortedArrayLength].action;
unsortedList[unsortedArrayLength].author;
unsortedList[unsortedArrayLength].subject;
unsortedList[unsortedArrayLength].time;  

ただし、これをコンパイルすると、次のエラーが表示されます:
Assign.exe の 0x5AC6516F (vcruntime140d.dll) で例外がスローされました: 0xC0000005: アクセス違反の書き込み場所 0x00000000。

string tit = tempBook->title;
string act = tempBook->action;
string aut = tempBook->author;
string sub = tempBook->subject;
char* tm = tempBook->time;

unsortedList[unsortedArrayLength].title = tit;
unsortedList[unsortedArrayLength].action = act;
unsortedList[unsortedArrayLength].author = aut;
unsortedList[unsortedArrayLength].subject = sub;
unsortedList[unsortedArrayLength].time = tm;  

次に、ウィンドウ memcpy.asm をポップアップし、カーソルを次の場所に置きます。

CopyUpByteLoop:
    mov     al, byte ptr [esi]
    mov     byte ptr [edi], al
    inc     esi
    inc     edi
    dec     ecx
    jne     CopyUpByteLoop  

要求された struct Book の定義:

    struct Book
{
    std::string title;
    std::string author;
    std::string subject;
    char* time;
    std::string action;
};

完全な関数は次のとおりです。

    void DB::insertBook(Book* tempBook)
{
    using namespace std;
    unsortedArrayLength++;
    string tit = tempBook->title;
    string act = tempBook->action;
    string aut = tempBook->author;
    string sub = tempBook->subject;
    char* tm = tempBook->time;

    unsortedList[unsortedArrayLength].title = tit;
    unsortedList[unsortedArrayLength].action = act;
    unsortedList[unsortedArrayLength].author = aut;
    unsortedList[unsortedArrayLength].subject = sub;
    unsortedList[unsortedArrayLength].time = tm;

    system("cls");

    cout << "You have " << unsortedList[unsortedArrayLength].action <<":\n" << endl <<
    unsortedList[unsortedArrayLength].title << endl <<
    unsortedList[unsortedArrayLength].author << endl <<
    unsortedList[unsortedArrayLength].subject << endl <<
    "on " << unsortedList[unsortedArrayLength].time << endl << endl;

    printToLog(tempBook);
}

オビワンを助けてください。あなたは私の唯一の希望です...

4

1 に答える 1

0

わかりました。配列のインスタンス化を大きくしました。配列の上限に達しているように見えました。配列は 2 で初期化されましたが、これで十分でしたが、そうではありませんでした。:( 知識を貸してくださった皆さん、ありがとうございました。

于 2016-04-24T02:25:45.730 に答える