Does anyone have a way to initialize an array of ints (any multi-byte type is fine really), to a non-zero and non -1 value simply? By which I mean, is there a w
int
One line with pointers!
for (int *p = a; p < (a + 30); p++) *p = 1;
Or if you're prematurely afraid of performance hit caused by repeatedly calculating (a + 30):
(a + 30)
for (int *p = a + 30 - 1; p >= a; p--) *p = 1;