>Subject: StrNCopy Problem
>From: "R�gis Daniel de Oliveira" <[EMAIL PROTECTED]>
>
>I'm getting a problem when using StrNCopy to copy a defined 
>lenght of a string into another. Sometimes, when a copy a odd 
>lenght from a string to another, the destination string  is not 
>terminated correctly
>

Per the Palm OS Reference documentation:
        "Copies up to n bytes from a source string to the destination 
        string. Terminates dst string at index n-1 if the source string 
        length was n-1 or less."

Seems like StrNCopy is working perfectly for you!  
(This API function does seem to match the strncpy() function)

Your code is the problem.  You need to explicitly terminate the 
destination string.
Example:
        StrNCopy(Variable2, Variable1, 5);
        Variable2[5] = '\0';

If you don't want to put the nul byte at the end you can take
advantage of the StrNCat() function
       *Variable2 = '\0';
        StrNCat (Variable2, Variable1, 5);

Roger Stringer
Marietta Systems, Inc  (www.RF-TP.com)


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

Reply via email to