David,
Thats the problem with using pointers to arrays. The only time you know
the size of the array (unless it is a c-style string) is when you create
the original array. If you want to know the size of an array, you need
to either pass that value into the function, or denote the end of the
array by assigning the last element to a specific value.
Remember that in c, you can access memory locations outside of an array,
there is no memory protection or bounds protection. If you declare int
array[10] and then say array[10] = 5, you have just corrupted your
memory system. In tinyos there is no memory protection, and it's very
easy to overwrite kernel or other memory. (there are no segmentation
faults).
-Paul
David Rodenas Herráiz wrote:
Hi all
How can I get the number of elements of an array?
For example, if you have a pointer to an array of 200 elements, get
this number.
You can't do this with sizeof. I've also tried with
sizeof(array)/sizeof(array[0]) but I don't get what I want.
Regards
David
------------------------------------------------------------------------
49 habitantes, 49 expertos en Windows 7. Así es Sietes, ¡Visítalo!
<http://www.sietesunpueblodeexpertos.com/>
------------------------------------------------------------------------
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help