int shifts[c] = {0};
The c is defined. Error: shifts maybe not be initialized. Why? What am I doing wrong here? I think it has something to do with c, but I am not sure. If I can't use the current declaration, how do I get around it? I tried it with vectors first:
vector<bool> shifts(c, false)
But, it didn't work. Had bad_alloc error.
int max = 0, min = 10000;
for (int i = 0; i != 2*no_shifts; ++i) {
int x;
fin >> x;
time.push_back(x);
if (max < x)
max = x;
if (min > x)
min = x;
}
c = max - min + 1;
chas to be a compile-time constant for the array declaration. Is it?cwhen you execute that line?maxandmindefined? Can you show more code, at least enough to see exactly whatcgets set to, ideally an entire but short programcis not a constant expression since it involvesmaxandminwhich are non-const. Variable-length arrays are not part of C++ and your compiler may have restrictions on how they can be used. (In C99, variable-length arrays may not be initialized.)