CRE Programmer's Guide
String and Memory Block Functions
Common Run-Time Environment (CRE) Programmer’s Guide—528146-004
8-24
Strncpy
•
If max_bytes is greater than the length of both strings and if the two strings have
different lengths but match to the end of the shorter string, the shorter string is
defined to be less than the longer string.
Example
INT sign;
STRING .s1[0:100] := ["Opus is a penguin",0];
STRING .s2[0:100] := ["Opus is a flightless water fowl",0];
sign := RTL_Strncmp_(s1, s2, 10); ! sign gets 0
Strncpy
The Strncpy functions copy not more than a specified number of characters from one
string to another.
dest
is a pointer to the destination string.
source
is a pointer to the string to copy.
max_bytes
specifies the maximum number of characters to copy; max_bytes must be a
positive number.
Return Value
The Strncpy functions return the address of the resulting string, @dest.
Considerations
•
The end of source is defined by the location of a zero (null) byte.
INT PROC RTL_Strncpy_( dest, source, max_bytes );
STRING .dest; ! out
STRING .source; ! in
INT max_bytes; ! in TNS
only
INT(32) PROC RTL_StrncpyX_( dest, source, max_bytes );
STRING .EXT dest; ! out
STRING .EXT source; ! in
INT(32) max_bytes; ! in TNS
only