I have the following code:
int board[5][5];
memset(board, INT_MAX, sizeof(board));
//printing out INT_MAX
cout << INT_MAX << endl;
for(int r = 0; r < 5; r++) {
for(int c = 0; c < 5; c++) {
cout << setw(3) << board[r][c];
}
cout << endl;
}
For some reason i am getting all -1
s in my array:
2147483647
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
How can I explain? Why aren't all the elements setting to INT_MAX?
When I print INT_MAX
it is printed out fine.