hi, I am doing a lab assignment for my C++ class and it wants us to use serveral pointer indirections for each variable. The program runs but then crashs and it seems to occur during the second iteration of a for loop in the arrayGet function. I'm not sure why, something to do with "Access violation reading location".

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
using namespace std;

bool vectorGet(vector<string> ****);
bool arrayGet(string ***, vector<string> ****);

int main()

vector<string> ****p;
string ***r;
p = new vector<string> ***;
r = new string **;

for(int x = 0; x < (*(*(*p)))->size(); x++)
        cout << (*(*(*(*p))))[x] <<endl; 

arrayGet(r, p);

for(int y = 0; y < (*(*(*p)))->size(); y++)
    cout << *(*r)[y] <<endl;

delete *(*(*p));
delete *(*p);
delete *p;
delete p;

delete *(*r);
delete *r;
delete r;


bool vectorGet(vector<string> ****p)
*p = new vector<string> **;
*(*p) =    new vector<string> *;
*(*(*p)) = new vector<string>;

string temp;

    fstream document("TopicAin.txt");     
    while(!document.eof() )
    getline(document, temp);

return true;

bool arrayGet(string ***r, vector<string> ****p)
*r = new string *;
*(*r) = new string[(*(*(*p)))->size()];

for(int y = 0; y < (*(*(*p)))->size(); y++)
    *(*r)[y] = (*(*(*(*p))))[y];    //crash happens here

return true;

The program reads from a file and fills up the vector then copies the vector to a array and then prints out both variables.

Any help would be great, thanks

I found my problem. LOL how do I delete this post since no one replied to my problem?

This question has already been answered. Start a new discussion instead.