私はこれを数時間試してみました。私は同様の問題を見つけることができませんでした(私はそれが行われていると確信していますが)。だから私の質問に。私がこれをコンパイルすると、大丈夫です。
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
{
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);
}
オビ=ワンを助けてください。あなたは私の唯一の希望です...
変数 'unsortedArrayLength'は定数ですか?そうでなければ、配列が正しく初期化されている可能性があります。なぜあなたは配列の長さ変数をインデックスとして使用するのでしょうか?これは、配列の終わりを過ぎて1つのインデックスを返すことになります。これは古典的な「1つずつのエラー」です。あなたの配列とそれをインデックスしている方法 – ciphermagi
私はちょうどBook *型のunsortedListであることを編集しようとしていました。私のインデックス== 1.別の関数の前回の操作のインデックスに1つのオブジェクトがあります – yorTsenoJ
構造体の定義。 – ciphermagi