Sunday, July 12, 2009

C++, problems using return?

int main()


{


int Array[3][3][3][3]={0}; // Array is created and all elements are set to 0


int RemoveCells=0;


srand((unsigned)time(NULL)); // Resets the number used in the random number generator to give a new random number each time





SetScreen(); // Sets the Sudoku grid


ArrayAssign(Array); // Assigns Array's elements a value


ArrayPlacer(Array); // Places the contents of Array into the Sudoku grid


Difficulty(RemoveCells);


SetPuzzleScreen(); // Sets the Sudoku puzzle grid


Hider(Array, RemoveCells); // Randomly hides around 50 cells in the Sudoku puzzle grid





gotoxy(28,48); //This is to move "Press any key to continue" below the Sudoku puzzle grid





return 0;


}





.......





My Difficulty function has RemoveCells passed in, depending on user input RemoveCells becomes 40, 50 or 60. But when I put





return RemoveCells;





at the the end, it doesnt return them, what am I doing wrong? :S

C++, problems using return?
i don't know, because you didn't post the code of Difficulty().





my guess is that it returns the value, but it's not assigned in your main function. Change the code to this:





RemoveCells=Difficulty(RemoveCells);





then it should work.


No comments:

Post a Comment