> From: I am johnny~
>
> Char* myFunction( void)
> {
>  Char *str1;
>  Char *str2;
>
>  str1 = MemPtrNew( 13);
>  StrCopy( str1, "Johnny Hsiao");
>  str2 = MemPtrNew( 6);
>  StrNCopy( str2, str1+7, 5);
>
>  return str2;
> }
>

The code you posted should work (except that you are allocating memory for
str1 and str2 to point to and then you never free that memory, so you have a
memory leak).  Call it like this to verify it yourself.

  Char msg[20];
  StrCopy(msg, myFunction());
  WinDrawChars(msg, StrLen(msg), 10, 20);

If it doesn't work for you, then your program probably has done something to
mess up the stack.


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

Reply via email to