I feel like something weird is happening. Basically I have a file that looks like this;
2
1 2
2 1
And what I want to do is read the second and third lines into arrays;
int n;
inputfile >> n;
int * tarray;
int * parray;
tarray = new int [n];
parray = new int [n]; // Store other numbers in arrays
for(int i=0; i < n; i++)
{
inputfile >> parray[n];
cout << parray[n] << endl;
}
for(int i=0; i < n; i++)
{
inputfile >> tarray[n];
cout << tarray[n] << endl;
}
This seems to work fine, but then when I read out an array value (parray[0], say) after this, I get nonsense values. No idea why.