Re: [GEN] multiple pointers

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 15 Oct 2000, Derek Parnell wrote:
>> ----- Original Message -----
>> From: "cense" <cense at MAIL.RU>
>> To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
>> Sent: Sunday, October 15, 2000 4:41 PM
>> Subject: [GEN] multiple pointers
>> 
>> 
>> 
>> > how can euphoria handle multiple indirection? how can i get the value at
>> > the end of the pointer chain? in my case the the variable is a
>> 
>> > // in C
>> > char **list;
>> 
>> In C, "char **list" is read as "list is a pointer to a pointer which points
>> to a character". Often this situation is called a "handle". It is common in
>> Windows programming and extremely common in Macintosh and Amiga programming.
>> In C, a "char *" usually means a character string which is terminated by a
>> zero byte.
>> 
>> So, in the example above, if "list" is an atom containing a 32-bit machine
>> address then I'd do the following...
>> 
>> atom list
>> atom charptr
>> integer char
>> sequence string
>> 
>>     -- Get the pointer to the character data
>>     charptr = peek4u(list)
>> 
>>     -- Initialize the sequence
>>     string = ""
>> 
>>     -- Get the first character
>>     char = peek(charptr)
>> 
>>     -- Repeat until we find the terminating zero
>>     while char do
>> 
>>         -- Append the character just picked up
>>         string &= char
>> 
>>         -- Point to the next character
>>         charptr += 1
>> 
>>         -- Grab it from memory
>>         char = peek(charptr)
>> 
>>     end while
>> 
>>     -- See what we got.
>>     ? string
>> 
>> ...but... if "list" is some other form of machine address, this method will
>> nnot work and you just might get a segmentation address.
>> 
>> ------
>> Derek Parnell
>> Melbourne, Australia
>> (Vote [1] The Cheshire Cat for Internet Mascot)

Thanks Derek! That elaborates a little on what Mark had to say but i now
believe my *major* problem was easlier in my code. But that does not mean
the problem i was trying to get solved here is wasted, i will need this
solution a little later.

-- 
evil, corruption and bad taste
  ^cense

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu