This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

array with names

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];
.
.
and each element of the array should have its special name like
1. actual_temperature
2. minimum_temperature
3. maximal_temperature
but the should share the same memory adress.

Sorry dont tell me Please read the manual, just give me a helpful hint.
Sincerly yours

Parents
  • #define actual_temperature my_array[1]
    #define minimum_temperature my_array[2]
    #define maximal_temperature my_array[3]

    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

Reply
  • #define actual_temperature my_array[1]
    #define minimum_temperature my_array[2]
    #define maximal_temperature my_array[3]

    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

Children
No data