Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

c++ exception thrown “read access violation” when dereferencing value from dynamic memory

void CustomerOrder::fillItem(Item& it, std::ostream& os) {
for (int i = 0; i < ItemCount; i++) {
    if (ItemList[i]->ItemName == it.getName()) {
        ItemList[i]->FillState = true;
        os << "Filled " << Name << ", " << Product << "[" << ItemList[i]->ItemName << "]" << std::endl;
    }
}
}

ItemList is of type (ItemInfo **), where I used dynamic memory for this object, it is a list of ItemInfo objects, and each has a variable "ItemName". I am trying to loop through the list to find the name and set its other variable "FillState" to true. My guess would be that something is wrong the way I am derefrencing the value, but I do not know exactly where.

I got an error thrown, saying"read access violation", as soon as this function gets called. I couldn't find where the problem is while debugging. Appreciate the help.

Comments