Right now, to set all items in an array to, say, 0, I have to loop through the entire thing to preset them.
Is there a function or shortcut which can defaultly set all values to a specific number, when the array is stated? Like so:
int array[100] = {0*100}; // sets to {0, 0, 0... 0}
std::vector<int> v (100 /* length */, 42 /* initial value */);{0*100}looks a bit strange. On one hand, 0 * 100 == 0 and correct (answer of Denise). On the other hand, it looks like a repetition of 0 is intended to express. That doesn't work that way. And, btw. 0 is the only possible value for an array initializer in that manner.[0]*3 -> [0, 0, 0]not[0*100] -> [0]. Unrelated: Be careful while using multiplication on lists in python you'd be victim of changes in sublist are relected across the list