// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int DIM = 2;

typedef char square[DIM][DIM];

void readsquare(char *fnm, square sq)
{
    ifstream f(fnm);
    string line;
    int i = 0;
    while(getline(f, line)) 
    {
        for(int j = 0; j < line.length(); j++) sq[i][j] = line[j];
        i++;
    }
    f.close();
}

int main()
{
    square sq;
    readsquare("sq.dat", sq);
    for(int i = 0; i < DIM; i++)
    {
        for(int j = 0; j < DIM; j++)
        {
            cout << sq[i][j];
        }
        cout << endl;
    }
    return 0;
}
