StrCat (or StrNCat) is defined as inserting S2 into S1 starting at the NULL
in S1.  You'll have to append S2 to S1 after the NULL manually.  You could
use MemMove or write a little loop to copy each char.

----- Original Message -----
From: "Michel.P" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Wednesday, November 20, 2002 5:04 PM
Subject: How to append NULL-char to string?


> I want to insert a null character at the end of a
> couple of strings and then concatenate (pack) them but
> I simply don't know how to get it to work.
> The way I try to do it now is like this:
>
> //Here his where we'll store the concatenated strings
> Char *packed;
> //Here's where we want to add the null chars
> Char *field1, *field2;
> .
> .
> .
> //Assume that field1+2 now have values asigned,
> WITHOUT null-terminator
> //+2 for null chars
> packed = MemPtrNew(StrLen(field1) + StrLen(field2) +
> 2);
> //Add 1 - presumably the null
> StrNCat(packed, field1, StrLen(field1)+1);
> //Here the string should be appended AFTER the null
> char
> StrCat(packed, field2);
>
> Apparently StrCat() overrites the null char (or so it
> seems).
> I'm lost, any help would be much appreciated, I've
> already spent way too much time on this one...
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
>



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

Reply via email to