1

I am writing a C function, but when I compile it with -Wall flag, it complains as follows:

warning: ‘sizeof’ on array function parameter ‘dayarray’ will return size of ‘const long int *’ [-Wsizeof-array-argument]

C Function

static int get_month_and_day(const long dayarray[], const size_t dayofyear, long* month, long* dayofmonth)
{
    unsigned char found = 0 ;
    const size_t numelements  = (sizeof dayarray)/ (sizeof *dayarray) ;
    ...
}

What would be a better way of determing the number of elements in the variable dayarray ?.

Community
  • 1
  • 1
Homunculus Reticulli
  • 65,167
  • 81
  • 216
  • 341
  • 5
    You have to keep track of it from the function that makes the array. Pass the length as an additional parameter – Kninnug Oct 14 '17 at 16:35

0 Answers0