How can a large sparse array be initialized conveniently in C? The code below works but becomes unwieldy for large arrays, basically a whole new way for off by one errors! For example, what if I want an array of length 200 all 0's except for 1's at indices 7, 62, 100, and 189. The values are known at compile time. I was wondering if macros can generate the array.
const char myArray[] = {0,0,1,0,0,0,0,0,1,0};
This question is for C++, but maybe a trick with structures would work in C also.