Ok now i am completely lost. The only change i made other than the one recommended was I plugged in a do-while loop so that the program will run until it reads in a size of -1. Now the program runs until it prints the SumRtDiag then just stops. Any suggestions?

Here is the code again:

#include <iostream>

#include <fstream>

#include <cstring>

using namespace std;

void PrintMatrix( int x[][20], int size)
{
    cout << "The current matrix is: " << endl;

    for(int i = 0; i < size; ++i)
    {
        cout << "\t";

        for(int j = 0; j < size; ++j)
        {
            cout << x[i][j] << "\t";
        }

        cout << endl;
    }

    cout << endl;
}

int SumRtDiag(int x[][20], int size)
{
    int d = 0;

    for(int i = 0; i < size; ++i)
    {
        d += x[i][i];
    }

    return d;
}

void DataIn(ifstream &fin, int x[][20], int size)
{
    for(int i = 0; i < size; ++i)
    {
        for(int j = 0; j < size; ++j)
        {
            fin >> x[i][j];
        }
    }
}

int SumCol(int x[][20], int size, int NumCol)
{
    int ColSum = 0;

    for(int i = 0; i < size; ++i)
    {
        ColSum += x[i][NumCol];
    }

    return ColSum;
}
int SumRow(int x[][20], int size, int NumRow)
{
    int RowSum = 0;

    for(int j = 0; j < size; ++j)
    {
        RowSum += x[NumRow][j];
    }

    return RowSum;
}
int FindSize(int x[][20], ifstream &fin)
{
    int m;

    fin >> m;

    return m;
}

int SumLftDiag(int x[][20], int size)
{ ...

Thanks for the help!

For my c++ class i have to write a code that will read integers in to a 2D array from a file and then, using functions/methods, determine if the array is a magic square. My problem is that when i build or compile i get "error C2664: 'DataIn' : cannot convert parameter 1 from 'std::ifstream' to 'std::fstream &'" Here is the code:

#include <iostream>

#include <fstream>

using namespace std;

void PrintMatrix( int x[][20], int size)
{
    for(int i = 0; i < size; ++i)
    {
        for(int j = 0; j < size; ++j)
        {
            cout << x[i][j] << "\t";
        }

        cout << endl;
    }
}

int SumRtDiag(int x[][20], int size)
{
    int d = 0;

    for(int i = 0; i < size; ++i)
    {
        d += x[i][i];

        return d;
    }
}

void DataIn(fstream &fin, int x[][20], int size)
{
    for(int i = 0; i < size; ++i)
    {
        for(int j = 0; j < size; ++j)
        {
            fin >> x[i][j];
        }
    }
}

int SumCol(int x[][20], int size, int NumCol)
{
    int ColSum = 0;

    for(int i = 0; i < size; ++i)
    {
        ColSum += x[i][NumCol];
    }

    return ColSum;
}

int SumRow(int x[][20], int size, int NumRow)
{
    int RowSum = 0;

    for(int j = 0; j < size; ++j)
    {
        RowSum += x[NumRow][j];
    }

    return RowSum;
}

int FindSize(int x[][20], ifstream fin)
{
    int m;

    fin >> m;

    return m;
}

int SumLftDiag(int x[][20], int size)
{
    int sum = 0;

    for(int i = 0; i < size; ...