How to return a list of numbers from a function?


i trying figure out easiest/best/standard/accepted/foolproof way return list of numbers (an array?) function, including how many numbers in list.

currently, doing passing in array reference, , returning number of elements put array.  used method in article http://forum.arduino.cc/index.php/topic,42934.0.html guide.  it's working, seems me there must better way, particularly since seems have predefine array , it's size before calling function.  (therefore, must make array @ least big expected result set, , when populating results make sure not go past end.)

my function is:
code: [select]
int isholiday(datetime dt, int *holidaylist)
where:
isholiday name of function (duh!)
datetime dt date-time structure containing month, day of month, weekday, year, etc.
holidaylist predefined array of integers hold results
and return value how many holidays occur on day , how many elements set in array, possibly zero.
i should note holidays enumated constant int values assigned them, there quite few of them, (see: http://www.holidayinsights.com) , there definite possibility date may match several of them, or may not match , return 0 , empty list.
this digital clock project reminds me of birthdays, anniversaries, standard, , weird/fun holidays on lcd display.
my regular day job programming in c#, , similarities-yet-differences between , straight c/c++ drive me nuts when try program arduino.

make global array , have function whatever array.
then other functions, or code in loop, can access array also.

i make variables global, lets code access anything.


Arduino Forum > Using Arduino > Programming Questions > How to return a list of numbers from a function?


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support