I'm trying to understand callbacks, and do get the idea, but do not understand why it is really needed.
Specifically, what added benefit does it provide over a normal function call? I'm looking at the accepted answer here : What is a "callback" in C and how are they implemented?
I have redone the same thing below, just without using function pointers. How is that different from this?
void populate_array(int *array, size_t arraySize)
{
   for (size_t i=0; i<arraySize; i++)
      array[i] = getNextRandomValue();
}
int getNextRandomValue(void)
{
   return rand();
}
int main(void)
{
   int myarray[10];
   populate_array(myarray, 10);
   ...
}
Is it only beneficial if lower-layer software needs to call a function that was defined at a higher-layer?
 
     
     
     
     
    