Read into a memory address

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

  1. ncohen macrumors newbie

    Mar 31, 2009
    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...

  2. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    I didn't understand exactly what you meant... but I'll try to give you something that would do what i think you want:
    /* 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.

  3. ncohen thread starter macrumors newbie

    Mar 31, 2009

Share This Page