When attempting the following code, I get a memory violation when I get half way through the array. It seems as though the array is being treated as a one dimensional array instead of two. Any help is appreciated.
int _tmain(int argc, _TCHAR* argv[])
{
int tempArray [numTemps][numMonths];
getData(tempArray);
system ("pause");
return 0;
}
void getData(int temps [][numMonths])
{
int i;
int j;
ifstream inFile;
inFile.open("Ch9_Ex9Data.txt");
if (!inFile)
{
cout << "Cannot open input file. \n";
system ("pause");
}
i =0;
while (!inFile.eof()) // Process each record in the input file
{
j = 0;
while (!inFile.eof() && j < 2) // Process each record in the input file
{
cout << "i = " << i << " j = " << j << endl;
inFile >> temps [i][j];
j = j++;
}
cout << "Month = " << i << " Low = " << temps [i][j-2] << " High = " << temps [i][j-1] << endl;
i = i++;
}
inFile.close();