# CopyString

void CopyString (char targetString[], int targetIndex, char *sourceString, int sourceIndex, int maximum#Bytes);

## Purpose

Copies the string that starts at position sourceIndex of sourceString to position targetIndex of targetString. CopyString stops copying when it encounters an ASCII NUL byte or when it has copied maximum#Bytes bytes. CopyString appends an ASCII NUL if it did not copy an ASCII NUL.

## Parameters

Input
Name | Type | Description
targetIndex | integer | Zero–based index specifying the location within the target string at which to begin copying bytes.
sourceString | string | String from which to copy bytes.
sourceIndex | integer | Zero–based index specifying the location of the bytes to be copied within the source string.
maximum#Bytes | integer | Specifies the maximum number of bytes, excluding the ASCII NUL, to copy into the target. If you do not want to specify a maximum number of bytes to copy, use –1 for maximum#Bytes.
| Note This value must be no greater than the number of bytes in the target variable, minus one.
Output
Name | Type | Description
targetString | string | Variable into which to copy bytes. If you want to use maximum#Bytes to prevent writing beyond the end of targetString, make sure to allow room for the ASCII NUL. For example, if maximum#Bytes is 40, the destination buffer should contain at least 41 bytes.
| Note You can use CopyString even when sourceString and targetString overlap.

## Return Value

None.