Its giving me this error for line
*(repetitions + x)++; inside this for loop. Any clues why?
for (int y = 0; y<hours; y++)
if (*(array + x) == *(array + y))
*(repetitions + x)++;
You can't increment the rvalue
repetitions + x. This is the same error as writing:
int a = 3; int b = 2; (a+b)++; // ????
++ operator requires an lvalue, i.e. the designation of a variable.
a+b is a temporary result and doesn't have a memory address, it can't be incremented.
It's possible that you meant to write
(*(repetitions + x))++;, which could be more clearly expressed as
This parses as
*((repetitions + x)++) -- that is, it tries to modify a constant address, then dereference it. Presumably you intended increment what the address pointed at instead.
You can do that a couple different ways. One would be to use parentheses. Another to use pre-increment:
++*(repetitions + x);
(*(repetitions + x))++;