0

I have this function:

byte GD_FindButton(BUTTON **array, TPoint *Touchposition)
{
    int i = 0;
    for (i = 0; i < sizeof(**array); i++)
    {
        if ((Touchposition->x > (*array)->x1) && (Touchposition->x < (*array)->x2) && (Touchposition->y > (*array)->y1) && (Touchposition->y < (*array)->y2))
            return (*array)->name;
        array++;
    }
    return 0;
}

where **array is a pointer of pointer declare as is:

BUTTON **button_array[2] = { &home, &start };

that contain

BUTTON home = { 20, 145, 70, 195, 'h' };
BUTTON start = { 84, 33, 236, 185, 's' };

I have to detect the size of the **button_array for prevent overflow during the for loop but I have problem to understand how to do. Can you help me? Thanks!!

Midas
  • 7,012
  • 5
  • 34
  • 52
  • You cannot use `sizeof` on array passed as function argument. The above thread explains why this is. – Midas Jun 07 '16 at 15:06
  • Maybe the answer here explains it better: http://stackoverflow.com/questions/24897716/sizeof-array-through-function-in-c – Midas Jun 07 '16 at 15:08

0 Answers0