Read into a memory address

Discussion in 'Mac Programming' started by ncohen, Mar 31, 2009.

  1. macrumors newbie

    Joined:
    Mar 31, 2009
    #1
    Hi everybody,
    I'm trying to read into a memory address in Objective-C... For example, I have the address 0x0078C900 and I want to store in a variable the 16 bits which start from this address! How can I do that? What kind of variable can I use?

    If you also know how to convert a signed signed integer into a int...

    Thanks!
     
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    I didn't understand exactly what you meant... but I'll try to give you something that would do what i think you want:
    Code:
    /* we'll assume that myAdr is a void * that has the address 0x0078C900 stored in it */
    short myShort = 0;
    myShort = *(short *)myAdr;
    
    myShort will now contain the 16 bits starting at the given address interpreted as a 16-bit integer value.

    As for the "signed signed integer", there is no such type. int is already a signed integer.

    -Lee
     
  3. thread starter macrumors newbie

    Joined:
    Mar 31, 2009

Share This Page