MemPtr = pointer;

recordH = DmQueryRecord(gDB, recordNum);     //Read the record
path = MemHandleLock(recordH);

path->array = MemPtrNew(sizeof(Int16)*noOfArrayValue);
for (index = 0; index < noOfArrayValue; index++)
{
        pointer  = (Int16 *) path->array[index];
        // ... get value of array[index] using pointer
        // (which I don't know how to do)
}

MemHandleUnlock(recordH);


When running  path->array = MemPtrNew(sizeof(Int16)*noOfArrayValue);
the program crash
why and how to fix it?

When I ignore this code ( path->array =
MemPtrNew(sizeof(Int16)*noOfArrayValue); )
the  pointer  could only get the first value of the array but not other
values,
so what is the problem?
thanks


"Caspar Heiden, vd" <[EMAIL PROTECTED]> ???
news:[EMAIL PROTECTED] ???...
        pointer  = (Int16 *) path->array[index];
        // ... get value of array[index] using pointer
        // (which I don't know how to do)

After the above assignment, you could treat pointer as if it was an
array (pointer[0], pointer[1], pointer[2])

An alternative, assuming pointer was declared as

Int16 *pointer;

is that you can simply increment pointer:

*pointer contains the first value, after you incremented it (pointer
++), it will contain the second, etcetera.

It is important to use the right type here, if you increment pointer,
the compiler looks at the type it 'points to' (Int16) and adds the size
of that (two bytes).

Good luck,

Caspar



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to