Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Pointer to memory

Reply
Thread Tools

Pointer to memory

 
 
MarkY
Guest
Posts: n/a
 
      10-10-2003
How does on "point" a pointer at a specific memory address? I have a
program where I've malloc'd some memory and need to move around and
make changes. I know I can move a pointer in the malloc'd storage by
incrementing a pointer. However, in this malloc'd storage, I have
stored addresses of other locations and would like to "jump" from one
memory location to another based on what I find in certain memory
ranges. Don't worry, I've taken care of word aligning, etc. etc.

So to recap:
1. I have malloc'd storage
2. I have written blocks of data into this storage (I know it's there
because I can traverse the entire storage and output the information
alas, by incrementing the pointer)
3. I need to jump from run location to another based on some of the
data I've added.


Thanks,
Mark
 
Reply With Quote
 
 
 
 
Andreas Kahari
Guest
Posts: n/a
 
      10-10-2003
In article < >, MarkY wrote:
[cut]
> So to recap:
> 1. I have malloc'd storage
> 2. I have written blocks of data into this storage (I know it's there
> because I can traverse the entire storage and output the information
> alas, by incrementing the pointer)
> 3. I need to jump from run location to another based on some of the
> data I've added.



Is this very different from

thing = memoryarray[memoryarray[i]];

or

thing = memoryarray[(int) memoryarray[i]];

or possibly

thing = memoryarray[converttoindex(&memoryarray[i])];

(where converttoindex() returns an int computed from the data
pointed to by the argument) ?


You're allowed to do that, but you're responsible for making
sure you store the right things at the right places with the
right types.


--
Andreas Kähäri
 
Reply With Quote
 
 
 
 
MarkY
Guest
Posts: n/a
 
      10-11-2003
Andreas Kahari <ak+> wrote in message news:<slrnbocv98.r55.ak+ >...
> In article < >, MarkY wrote:

<snip>
>
> Is this very different from
>
> thing = memoryarray[memoryarray[i]];
>
> or
>
> thing = memoryarray[(int) memoryarray[i]];
>
> or possibly
>
> thing = memoryarray[converttoindex(&memoryarray[i])];
>
> (where converttoindex() returns an int computed from the data
> pointed to by the argument) ?
>
>
> You're allowed to do that, but you're responsible for making
> sure you store the right things at the right places with the
> right types.


Thanks Andreas. I was able to use a slightly modified version of Option 3.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to an array vs pointer to pointer subramanian100in@yahoo.com, India C Programming 5 09-23-2011 10:28 AM
Pointer to pointer or reference to pointer A C++ 7 07-05-2011 07:49 PM
Pointer to pointer Vs References to Pointer bansalvikrant@gmail.com C++ 4 07-02-2009 10:20 AM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM



Advertisments