I'm back again, this class just goes a bit too fast, but I think I'm getting the hang of it slowly. Anyways, I'm trying to create a 5x5 magic square, I believe that my code is really close, and it compiles without error. But, in the terminal window it says "Program received signal: “EXC_BAD_ACCESS”." and I can't figure out what's wrong, I would greatly appreciate some help
(I would go to the tutor, but the only times he is available are when I am in other classes
)
Code:
#include <iostream>
using namespace std;
void print(int array[][5]);
void zerofill(int array[][5]);
void magic(int array[][5]);
void colcheck(int array[][5],int row,int col);
void rowcheck(int arrray[][5],int row,int col);
void filledcheck(int array[][5],int row,int col);
int main()
{//main
int array[5][5];
zerofill(array);
magic(array);
print(array);
return 0;
}//main
void zerofill(int array[][5])
{//int zerofill
for(int i=0;i<5;i++)
{//for
for(int x=0;x<5;x++)
{//for#2
array[i][x]=0;
}//for#2
}//for
}//int
void print(int array[][5])
{//void print
for(int i=0;i<5;i++)
{//for
for(int x=0;x<5;x++)
{//for#2
cout << array[i][x] << "\t";
}//for#2
cout << endl << endl;
}//for
}//void
void magic(int array[][5])
{//void magic
int row = 0;
int col = 2;
int i = 1;
array[row][col] = i;
for (i=2;i<26;i++)
{//for
row--;
col++;
colcheck(array,row,col);
rowcheck(array,row,col);
filledcheck(array,row,col);
array[row][col] = i;
}//for
}//void magic
void colcheck(int array[][5],int row,int col)
{//void colcheck
if (col > 4)
{//if
col = 0;
}//if
}//void
void rowcheck(int arrray[][5],int row,int col)
{//void rowcheck
if (row < 0)
{//if
row = 4;
}//if
}//void
void filledcheck(int array[][5],int row, int col)
{//void filledcheck
if (array[row][col] > 0)
{//if
row++;
if (row > 4)
{//if#2
row = 0;
}//if#2
}//if
}//void