On Sat, Oct 04, 2003 at 05:15:23PM +0800, Brian wrote: > Has anyone encountered a problem when copying a data of type > unsigned characters to Char*? > > unsigned char* thisone= ""; > unsigned long i = 0; > > Char* putHere = 0; > putHere = (Char*)(thisone + i );
I have noted that typecasting is somewhat different under the palm, and doing some unforgiving things like in a print, using "%d" but feeding it a long, can cause a crash (which would never happen in gcc for Solaris, etc). I personally use unsigned and signed chars and don't have the specific problem you mention, but I can see that it might type-cast confuse the compiler in your mixing of the long, etc. Try a couple of things. First, try simply 'putHere = (Char *)thisone' If that works... print out both values... are the the same address? If so, good - now add the long in. Otherwise, if it doesn't work, try typecasting 'thisone's value as a long and then adding that in via another type cast. I mean, if you look at your line you have three typecasts in it... and one of those is not implied (e.g., your parenthesis have an unsigned char and long math). So me thinks it's mak'n an assumption that your not. So, for example, one of the following should work: 1) putHere = (Char *)thisone; putHere += (unsigned char *)i; 2) putHere = (Char *)(thisone + (unsigned char *)i); -- David Cook -- Cookware Inc. -- [EMAIL PROTECTED] TQworld and tranquility: www.TQworld.com Cookware Corporate: www.cookwareinc.com Hawaii/Asia Office: (808) 966-5049 (david cook) Mainland US Office: (317) 769-5049 (deborah sellers) Have you had tranquility today? Play now at http://www.tqworld.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
