You're destination buffer (*Market) needs to be large enough to hold 
*Market and the user input.  It works the other way because enough 
memory exists to copy both strings to the "Share" buffer.  If the user 
enters 123 characters then the other "Share" buffer would overflow and 
the app would crash also.  Why not something like this.  I don't have 
the api in front of me but you should get the picture.

Charptr temp = MemPtrNew(strlen("Market") + strlen(Share) + 1);
StrCopy(temp, Market);
StrCat(temp, Share);

Benjamin Brazil wrote:

> Hello,
> I am trying to concatenate some strings together but am having some 
> problems. I declare a "char Share[128]" string, as this is used to 
> hold text input from a text field entered by the user. I am trying to 
> concatenate this string with another string of type "char *Market" 
> which is just constant text, so that the resulting string holds 
> firstly the contents of the Market string and then the contents of the 
> Share string.
> 
> I am using the StrCat function as follows:
> 
> StrCat(Market, Share);
> 
> The code will compile however when it runs the program crashes and 
> returns the message that the program wrote to the storage heap and 
> that I should use a Palm OS function instead.
> 
> However, using the StrCat to concatenate the strings in the other way 
> round e.g. StrCat(Share, Market); does work.
> 
> I assume that the problem is something to do with the string being in 
> the form "char Share[128]" which is necessary to allow for the user 
> interface text input.
> Do I need to cast the Share[128] into a *Share for this to work? If 
> this is the case could someone tell me how this is done, or if the 
> problem lies elsewhere.
> I would be grateful for any assistance.
> Thank you,
> 
> Benjamin Brazil.
> 
> 
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos: 
> http://photos.msn.com/support/worldwide.aspx
> 
> 


-- 
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