Why the unsuccessfulness of extracting pointer dereference from vector is due to the problem of permission?

#include "EleAly.h"

This is my calling function:

void step1_1(char* Filepath1_1 ,const char* EndFilepath1_1)
    vector<char*> filevector1_1= GetFileList(Filepath1_1);
    vector<cube*> AllImgData;
    vector<char*> TempFilePath;
    double GeoTransform[6] = { 0 };
    int Bands[] = { 1 };
    string Pro = "pro";
    string* ProRef = &Pro;
    int bnum = sizeof(Bands) / sizeof(Bands[0]);
    char temp[300];
    strcpy(temp,EndFilepath1_1 );
    strcat(temp, "\\1_1Temp\\tempData");
    for (int j = 0; j < filevector1_1.size(); j++)
        int number = j + 1;
        char TEMPNum[1];
        itoa(number, TEMPNum, 10);
        char TempFilePathChar[300];
        strcpy(TempFilePathChar, temp);
        strcat(TempFilePathChar, TEMPNum);
    for (int i = 0; i < filevector1_1.size(); i++)
        int iWeight = GetXSize(filevector1_1[i]);
        int iHeight = GetYSize(filevector1_1[i]);
        int iBNum = GetBandNumbers(filevector1_1[i]);

        cube Imgdatas(iWeight, iHeight, bnum);
        cube* ImgData = &Imgdatas;
        ReadImgInfo(filevector1_1[i], iBNum,
            iWeight, iHeight,
            GeoTransform, Bands, ProRef, ImgData);
    for (int k = 0; k < (filevector1_1.size()); k++)
        HRefAly(AllImgData[k], TempFilePath[k], ProRef, GeoTransform);

And this is the function:

    void HRefAly(cube* ImgData,const char* HRefAlyFilePath,string* RefInf,double Trans[6])
            int nrow = ImgData->n_rows;
            int ncol = ImgData->n_cols;
            cube TEMPImgData = *ImgData;

In the last assignment of cube tempimgdata, an error was reported in (arrayops::copy of armadillo):

There is an unhandled exception at 0x00007ff80e7612db (vcruntime140d. DLL) (in Demo1. Exe): 0xc0000005: an access conflict occurred when reading the location 0x000000000000000.

But when I directly use a * imgdata value instead of using allimgdata [k] to call the pointer value in the container, the program does not report an error.

(This code is just for testing. In fact, there is only one file in the filelist. )

Why? No relevant documents were found.

update**** Thank you for helping me find the error of


When reading multiple files, it is clear that he has problems.But in fact, I only used one file for testing. As shown in the following screenshot, at the node where the error was reported, he has successfully read the matrix and successfully displayed the correct ncol, nrow. The problem here is that I can't assign the input cube * of the function to the new tempcube by dereference. I hope you can help me.

Error code

Position displayed when error is reported

asked on Stack Overflow May 13, 2021 by 唐欣悦 • edited May 13, 2021 by 唐欣悦

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0