I'm having an issue with my dynamic array. I'm trying to input the values that are into a text file into a dynamic array of length where size is the size of my text file.
For some reason I'm getting -842150451 repeated, idk if its something simple as not properly intializing it or maybe im using a << in the wrong way.
PS: I tried debugging and even if I print out the individual index, I still get that value.
My code:
cout << "\nEnter a command and file ";
getline(cin, line);
command = line.substr(0, line.find(" "));
names = line.substr(line.find(" ")+1);
ifstream readText;
readText.open(names += ".txt");
int size;
readText >> size;
int *someArray = new int[size];
if (command == ("Start"))
{
for (int i = 0; i < size; i++)
{
readText >> someArray[i];
}
for (int i = 0; i < size; i++)
{
cout << someArray[i] << endl;
}
}
else if (command == "do this")
{
//used to test to see if it works
cout << someArray[0] << endl;
cout << someArray[1] << endl;
cout << someArray[2] << endl;
}
the contents are just values like
94032
233332
2121
112
423424