Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/08/07 06:32
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#142922 - Two things that are definitly wrong
Responding to: ???'s previous message
Hallo Tomas

1. You can't return an array from the function this way. It is valid inside the function only. One possible solution, add 'static' to the array defintion.

2. The valid array index is 0,...19 only, so the loop can't be
for (i = 0; i < 21; i++) but for (i = 0; i < 20; i++) only.
My preferred solution is a global defintion

#define ArrayElementCount(X) (sizeof(X)/sizeof(X[0]))

then be used for all arrays in the project, like

for (i = 0; i < ArrayElementCount(temperature_array); i++)

this way I can easily modify the array length, by just edit
ONE single place, the variable definition.

Best regards, Juergen


List of 13 messages in thread
TopicAuthorDate
help required with array manipulation in c#            01/01/70 00:00      
   just having formatted            01/01/70 00:00      
   array not float?            01/01/70 00:00      
      Try This            01/01/70 00:00      
         but be sure to comment it carefully!            01/01/70 00:00      
   Why do you keep saying C# ??            01/01/70 00:00      
   Two things that are definitly wrong            01/01/70 00:00      
      Two things wrong with thing 1            01/01/70 00:00      
         Sorry and Thanks            01/01/70 00:00      
   Also..            01/01/70 00:00      
      ...and, 8051 specifically            01/01/70 00:00      
         8051 in C programming            01/01/70 00:00      
            first and second            01/01/70 00:00      

Back to Subject List