Home>

I'm trying to use LoadDivGraph from the DX library in C ++

An unhandled exception occurred in 0x00007FF7C1B69BAA (Project1.exe): 0xC0000005: An access violation occurred while reading location 0x0000000000000040. Has occurred
Corresponding source code
#include "DxLib.h"

int WINAPI WinMain (_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) {
 if (DxLib_Init () == -1) {return -1;} // DX library initialization process-Exit immediately if an error occurs
  ChangeWindowMode (TRUE);
  SetGraphMode (1280, 720, 16);// Graphic screen enlargement
  SetTransColor (255, 255, 255);// Transparent color setting (white)
  SetDrawScreen (DX_SCREEN_BACK);// Drawing range setting (back screen)

int passerby1 [3];
 LoadDivGraph ("passerby1.png", 3, 3, 0, 152, 157, passerby1);
int i = 0;
while (i! = 3) {
DrawGraph (x, 0, passerby1 [i], FALSE);
++ i;
}
DeleteGraph (passerby1 []);


   DxLib_End ();// Termination process of using DX library
    return 0;// Exit the software

}
What I tried

I looked it up, changed variables, and used pointers.

Supplementary information (FW/tool version, etc.)

Visualstdio 2019

  • Answer # 1

    I have not confirmed the operation, butYNumIs1So what?

    --LoadDivGraph ("passerby1.png", 3, 3, 0, 152, 157, passerby1);
    + LoadDivGraph ("passerby1.png", 3, 3, 1, 152, 157, passerby1);