// Ch. 8 Demo Program #3
// Purpose - to demonstrate opening a file for input and reading from the file.

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

int main()
{
   ifstream infile("data.txt");
   int matrix[3][3];               // matrix of integers
   int row = 0;
   int col = 0;

   for (row = 0; row < 3; row++)
   {

      for (col = 0; col < 3; col++)
      {
         infile >> matrix[row][col];  // reading matrix from file
      }

   }

   for (row = 0; row < 3; row++)      // displaying matrix
   {

      for (col = 0; col < 3; col++)
      {
         cout << matrix[row][col] << " ";
      }

      cout << endl;                   // advancing to next row
   }

   return 0;
}// end of main