//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);

----------------- remove this -------------------
//Add 1 - presumably the null
StrNCat(packed, field1, StrLen(field1)+1);
//Here the string should be appended AFTER the null
char
StrCat(packed, field2);

--------------- change with this ---------------------
MemMove(packed,field1,StrLen(field1));
packed[ StrLen(field1) + 1 ] = 0;
MemMove(
    (packed + StrLen(field1) + 1) ,
    field2,
    StrLen(field2));
packed[ StrLen(field1) + 1 + StrLen(field2) + 1 ] = 0;

must be ok... sure, you can optimize this ...



----- Original Message -----
From: "Matt Graham" <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Monday, November 25, 2002 5:51 PM
Subject: Re: How to append NULL-char to string?


> Michel.P wrote:
> > Hi Henk,
> >
> > I thought one couldn't copy a null string using
> > StrCopy(): I tried that before posting my question
> > (but usting '\0' instead of "\0") and it gave me an
> > error, and I believe someone in another post said that
> > you can't StrCopy() null....?
>
> This is sort of basic but no one else said anything so I want to make
> sure you know this.
> '\0' and "\0" are 2 different things.
> '\0' evaluates to type (char) with value 0.
> "\0" is a type (char *) with value "\0".
> If you tried passing '\0' to any string functions, it would probably not
> work, because it would be like passing a null pointer as a parameter.
>
> Matt
>
>
> --
> 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