Admin Production ni-theme
Current Publication

CopyString

LabWindows/CVI

CopyString

void CopyString (char targetString[], int targetIndex, char sourceString[], int sourceIndex, ssize_t maximumBytes);

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 int Zero–based index specifying the location within the target string at which to begin copying bytes.
sourceString char [] String from which to copy bytes.
sourceIndex int Zero–based index specifying the location of the bytes to be copied within the source string.
maximumBytes ssize_t 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 char [] 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.

Additional Information

Library: Formatting and I/O Library

Include file: formatio.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Examples

Refer to the following examples that use the CopyString function:

  • userint\TimeDateUnits.cws

    Open example
  • userint\custctrl\toolbar\tooldemo.cws

    Open example