CRE Programmer's Guide

String and Memory Block Functions
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
8-19
Strcpy
If str1 and str2 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_Strcmp_(s1, s2); ! sign gets a positive number
Strcpy
The Strcpy functions copy one string to another.
dest
is a pointer to the destination string.
source
is a pointer to the string to copy.
Return Value
The Strcpy functions return the address of the resulting string, @dest.
Considerations
source must be terminated by a zero (null) byte to stop the scan.
If the strings overlap, data is not preserved. That is, if dest begins within source,
the string at
dest might not be a copy of what was stored at source. For
example, Figure 8-1
and Figure 8-2 on page 8-20 show the before image and after
image from the following code sequence:
STRING .s[0:11];
STRING .d;
s ':=' "ABCDEFGHIJKL";
@d := @s[4];
d ':=' s FOR 12 BYTES;
INT PROC RTL_Strcpy_( dest, source );
STRING .dest; ! out
STRING .source; ! in TNS only
INT(32) PROC RTL_StrcpyX_( dest, source );
STRING .EXT dest; ! out
STRING .EXT source; ! in TNS only