I eventually figured it out. As I kept saying, the problem was in how I was populating the array. Here’s an entire section of code using a for
loop which correctly populates my pointer array:
#include <iostream>
#include <fstream>
#include <string>
#include <new>
using namespace std;
int main()
{
int * arraySize;
arraySize = new int;
*arraySize = 483;
int * temp;
temp = new int;
*temp = 0;
int * x = 0;
x = new int;
*x = 0;
ifstream file;
file.open("test.txt");
int* intArray = new int[*arraySize];
for (* x = 0; *x < *arraySize; (*x = *x + 1))
{
file >> *temp;
intArray[*x] = *temp;
cout << intArray[*x] << endl;
}
delete[] intArray;
cout << "\n";
system("pause");
return 0;
}
0
solved Write to dynamic array