Visual C++ is saying my void function needs a return value
I compiled this on my mac, and it worked perfectly, but now I am trying to compile this with Visual c++ (using windows 7)
Heres the build log:
Command Lines Creating temporary file "c:\Users\Jonathan\Documents\Visual Studio 2008\Projects\magicsquare\Debug\RSP00000822923000.rsp" with contents [ /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\magicsquare.cpp" ] Creating command line "cl.exe @"c:\Users\Jonathan\Documents\Visual Studio 2008\Projects\magicsquare\Debug\RSP00000822923000.rsp" /nologo /errorReport:prompt"
Output Window Compiling... magicsquare.cpp c:\users\jonathan\documents\visual studio 2008\projects\magicsquare\magicsquare.cpp(224) : error C4716: 'check' : must return a value
Results Build log was saved at "file://c:\Users\Jonathan\Documents\Visual Studio 2008\Projects\magicsquare\Debug\BuildLog.htm" magicsquare - 1 error(s), 0 warning(s)
my function header and function
void **check (int **, int);
void **check(int **matrix, int size)
{
//check if first row and last row are the same
int rsum = 0, rsum2 = 0;
bool rowflag = false;
for(int i = 0; i < size; i++)
{
rsum += *(*(matrix + 0) +i);
rsum2 += *(*(matrix + size - 1) +i);
}
//check if first column and last column are the same
int csum = 0, csum2= 0;
bool columnflag = false;
for(int i = 0; i < size; i++)
{
csum += *(*(matrix + i) + 0);
csum2 += *(*(matrix + i) + size - 1);
}
//check if diagonals are the same
int diagonal = 0, diagonal2 = 0;
bool diagonalflag = false;
for(int i = 0; i < size; i++)
diagonal += *(*(matrix + i) + i);
int m = 0;
int n = size - 1;
while (m <= size - 1)
{
diagonal2 += *(*(matrix + m) + n);
m++;
n--;
}
//if row, column, diagonal are the same
if (rsum == rsum2 && rsum2 == csum && csum == csum2 && csum2 == diagonal && diagonal == diagonal2)
cout << "This is a Magic Square\n" << endl;
else
cout << "This is not a Magic Square\n" << endl;
}
heres the entire code if needed http://pastie.org/691402