TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALEX WALKER
from: FRANK SCHMID
date: 1997-12-10 21:48:00
subject: Re: Finding the end of an array?

Hi Alex,
>      (...) is there a way
>      to test for or find the end of the array without having the size of
>      the array passed to the function?
Arrays are passed to a function by the address of the first element.
If you want to determine the end of an array you must uniquely define the  
end of an array, e.g. you can define that every array you use must end  
with a 0-element, regardless what type of array you are using.
The only thing you have to do is to walk straight through the array and  
test for this end-member.
Its practicable to define the end-element in a way that this special  
element does'nt occur in the range of values that are used by your data.
Another way is to handle special elements by using escape-sequences:
     You define value x as escape sequence. When x is encountered
     the next element is tested. If that one is x again, assume
     that this two elements mean one x, else that value is the
     special data (maybe the end of the array or something else)
bye
Frank
--- XPoint
---------------
* Origin: Alles ist relativ ... (2:245/6837.11)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.