Does anybody know how to change the default value when initializing an array?
If I want to initialize a multidimensional array of ints (default value for int is 0) and I want it to initialize with -1, is there any way to get around it without having to go like:
int myArray [HEIGHT][WIDTH];
int n, m;
for (n = 0; n < HEIGHT; n++)
for (m = 0;m < WIDTH; m++)
myArray[n][m] = -1;
I don't like this approach since it's a nested loop and the idea is to speed up, plus I think it's very cumbersome.
Thanks
created
last reply
- 5
replies
- 203
views
- 4
users