// Program TwoDim manipulates a two-dimensional array
// variable.                                        

#include <iostream>
#include <fstream>
using namespace std;

const int ROW_MAX = 8;
const int COL_MAX = 10;

typedef int ItemType;

typedef ItemType TableType[ROW_MAX][COL_MAX];

void  GetTable(ifstream&, TableType, int&, int&);
// Reads values and stores them in the table.

void  PrintTable(ofstream&, const TableType, int, int);
// Writes values in the table to a file. 

int  main ()
{
    TableType  table;
    int  rowsUsed;
    int  colsUsed;
    ifstream  dataIn;
    ofstream  dataOut;

    dataIn.open("twod.dat");
    dataOut.open("twod.out");
    GetTable(dataIn, table, rowsUsed, colsUsed);
    PrintTable(dataOut, table, rowsUsed, colsUsed);
    return 0;
}
                                                           
//***************************************************    
                                                     
void  GetTable(ifstream&  data, TableType  table,
               int&  rowsUsed, int&  colsUsed)
// Pre:  rowsUsed and colsUsed are on the first line of 
//       file data; values are one row per line       
//       beginning with the second line.                
// Post: Values have been read and stored in the table.                

{
    ItemType  item;
    data  >> rowsUsed >> colsUsed; 

    for (int row = 0; row < rowsUsed; row++)
        for (int col = 0; col < colsUsed; col++)
         
          // FILL IN Code to read and store the next value.                                                          
}

//****************************************************     

void  PrintTable(ofstream&  data, const TableType  table, 
                 int  rowsUsed, int  colsUsed)
// Pre:  The table contains valid data.
// Post: Values in the table have been sent to a file by row, 
//       one row per line. 
{                                                           
                                                            
    // FILL IN Code to print table by row.               
                                                            
}

