We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello to all of you, is there a way to have a array and give each element of the array a special name? An example:
float my_array[20]; . . for(i=0;i<20;i++) send(my_array[i]; . .
Hallo to everybody. Now being back from camping-holiday in Italia i wana thank you for your help.
#define actual_temperature my_array[1] #define minimum_temperature my_array[2] #define maximal_temperature my_array[3]
this fits perfect to my requirements, thank you Dan, i would have send you a picture-postcard from Pisa if i have had your adress ;-)
This hint is very helpful, everybody needs a little help if there are tomato-slices on front of your eyes ;-)
this fits perfect to my requirements,
It is a fairly ugly way to do this and will confuse the heck out of anyone trying to maintain it.
Use a union instead. At least this makes it clear which array you're actually referencing to.
this fits perfect to my requirements
Then why not just declare these three variables instead of an array?
Or make them fields in a struct, so you can send the entire block of three variables with one call to the send() routine.
It quite definitely doesn't --- it clearly fails the "have the same address" criterion. And neither is it perfect, in any useful interpretation of the word. A struct would be a whole lot more readable.
hides the fact that it is an array wheras #define MY_ARR_actual_temperature 1 #define MY_ARR_minimum_temperature 2 #define MY_ARR_maximal_temperature 3
and accessing it by my_array[MY_ARR_actual_temperature] would not
I consider it important that an 'array indicator' e.g. MY_ARR_ be included in the offset name, I have found horrendous bugs where the offset from your_array was used on my_array creating a very tough bug (nobody could 'see' it). e.g. if no 'array indicator' was included, could you spot your_array[actual_temperature] in a reasonable time?
Erik