The code is wrong, but not for the reason given.
test[cDataNeeded] is exactly cDataNeeded cells long (8 in this case). The
problem is that "012345678" is 10 cells in length: the nine chars visible
between the quotation marks plus one for the null byte implicit at the end
of a string literal.
>
> const int cDataNeeded = 8;
> char test[cDataNeeded];
>
> StrCopy(test, "012345678");
>
> This code is WRONG, WRONG, WRONG and will cause memory
> corruption. The
> reason is that test[cDataNeeded] is only cDataNeeded - 1
> cells long and the
> last line writes a NULL byte into whatever follows test in
> memory (some part
> of the stack in this case?). If you're working with allocated memory
> (MemPtrNew) then you'll corrupt the heap.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/