Beginner programmer here. I'm getting an access violation error in my directed graph program, and I'm wondering if anyone can tell me why.
Here's the trouble code (don't worry, it's not much). This code is from my main function. I've just read some info in from a file, parsed it, and am trying to insert it into a bucket using a function called InitialInsert.
//Store parsed file values
sourceCity = line[0];
destinationCity = line[1];
miles = stoi(line[2]);
cost = stoi(line[3]);
//Insert parsed values into Info bucket
graph.InitialInsert(sourceCity, destinationCity, miles, cost, size++); //Size is initialized to 0
This is the initial insert function.
//InitialInsert function
void Graph::InitialInsert(string source, string destination, int distance, int price, int index)
{
InfoBuckets[index]->sourceCity = source;
InfoBuckets[index]->destinationCity = destination;
InfoBuckets[index]->miles = distance;
InfoBuckets[index]->cost = price;
}
And this is from my header file.
static int const ARRAY_SIZE = 1000;
struct InitialInfo
{
string sourceCity;
string destinationCity;
int miles;
int cost;
};
InitialInfo* InfoBuckets[ARRAY_SIZE];
I'm getting the error "Access violation reading location 0xCCCCCCE4" when I hit the first line of my InitialInsert function. This is probably a silly problem, but can anyone help me out?