Chapter Contents |
Previous |
Next |
Command Directory |
Copy One or More Items to a New Location
co{py}
copy
command copies items from one location to another. The copy
command is used to copy a string, address, array, pointer,
or one or more expressions to a location. STRING is a string literal, set
off by double quotation marks. DESTINATION is a pointer, address, or array
name. In the following format discussions, SOURCE and DESTINATION are expressions.
Format 1: Format 1, similar to the
strcpy
function, copies a string literal specified by the STRING argument
to the location specified by the DESTINATION expression. A comma must follow
the DESTINATION argument.
Format 2: Format 2, similar to the
memcpy
function, copies a string literal. The string literal to be
copied is specified in the STRING argument (set off by double quotes). BYTES
is an integer that indicates the number of bytes to be copied to the location
specified by the DESTINATION expression.
typedef
function.
long signed long unsigned long double int signed int unsigned int float short signed short unsigned short enum char signed char unsigned char
The result of using Format 3 is analogous to the following:
memcpy(DESTINATION,SOURCE,((sizeof (CTYPE1 or CTYPE2)) * COUNT)
CTYPE1 overrides the declared types
of both the DESTINATION
and SOURCE arguments. If the SOURCE or DESTINATION argument does not have
a specific type, the type defaults to
char
. For absolute addresses,
the default type is
char
and the size of the pointed-to
expression is 1.
Format 4: Format 4 copies the contents
of a memory location pointed to by SOURCE to the location specified by the
DESTINATION expression until the null terminator
\ 0
is encountered in the
SOURCE expression. The keyword str
specifies
a string copy that is similar to
strcpy
. SOURCE is a pointer,
address, or array. The string delimiter
\ 0
is the last byte copied.
copy a+5, \ (b+2) |
copy
command examples are based on the following declarations:
char *cp, *s, *d; struct XYZ {int a; double b;} xyz, xarr[5] , yarr[5] ; int intarr[5] ;
copy cp, "abcd"
abcd
to the location pointed to by
cp
.
copy cp, "abcd", 4
abcd
) into the location
pointed to by
cp
(the null terminator
\ 0
is not copied).
copy xarr, yarr, 5
yarr
into the array
xarr
.
copy &xyz, &xarr[2]
xarr[2]
into
xyz.
copy d, s, 10
s
to the location pointed to by
d
.
copy d, s, str
s
into
d
.
copy intarr (int) {10,20,30,40,50}
intarr
.
PROFILE | no |
configuration file | no |
Source window prefix | none |
copy
command uses command scope to resolve references to all identifiers.
Successful: 0 | |
Unsuccessful: 1 |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.