C++ parsing data to 2d array, error : 0xC0000005

-3

i have global variable string dataArray[][4] = {""}; and i have procedure or function

void bacaFile(){
    fstream file;
    string line;
    int barisData = 0;

    /* mulai membuka file */
    file.open("read.txt");
    int index = 0;
    string data;
    while(getline(file, line, '\n')){
        int kolomData = 0;
        while((index = line.find(",")) != string::npos) {
            data = line.substr(0, index);
            line.erase(0, index + 1);
            dataArray[barisData][kolomData] = data.c_str();
            kolomData++;
        }
        barisData++;
    }
    file.close();
}

i try to get data on read.txt with total 15 rows and add to dataArray but i have error code : 0xC0000005. in my opinion it's because sizeof uses sizeof dataArray / sizeof dataArray[0] is 1 not 15. I searched but didn't find it yet.

sorry for bad.

c++
arrays
multidimensional-array
asked on Stack Overflow Dec 14, 2018 by iam

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0