LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

_mbsnbcpy

_mbsnbcpy

char *_mbsnbcpy (char targetString[], const char sourceString[], size_t maxBytes);

Purpose

Copies a specified number of bytes from a source string to a target string. The function does not copy bytes following an ASCII NUL byte. If copying takes place between two objects that overlap, the behavior is undefined.

Refer to the Programming for Multibyte Character Sets in LabWindows/CVI topic for information about working with multibyte character sets.

Parameters

Input
Name Type Description
sourceString const char [] Contains a pointer to the NUL-terminated source string from which a specified number of bytes are copied into the target string.
maxBytes size_t Specifies the maximum number of bytes that are copied from the source string into the target string, according to the following conditions:
  • If part of a multibyte character lies beyond this maximum number, the character is not copied, and an ASCII NUL byte is appended to the target string.
  • If the source string is shorter than the length specified in this parameter, ASCII NUL bytes are appended to the target string until maxBytes are written.
  • If the source string is longer than the length specified in this parameter, no ASCII NUL bytes are written to the target buffer.
  • If you want to guarantee that an ASCII NUL byte is at the end of the copied bytes, you can use the following:

    _mbsnbcpy (target, source, n);
    target[n] = 0;
Output
Name Type Description
targetString char [] Contains the target string to which the specified number of bytes from the source string is copied, according to the following conditions:
  • If part of a multibyte character lies beyond maxBytes, the character is not copied, and an ASCII NUL byte is appended to this parameter.
  • If the source string is shorter than maxBytes, ASCII NUL bytes are appended to the contents of this parameter until maxBytes are written.
  • If the source string is longer than maxBytes, no ASCII NUL bytes are written to the contents of this parameter.
  • If you want to guarantee that an ASCII NUL byte is at the end of the copied bytes, you can use the following:

    _mbsnbcpy (target, source, n);
    target[n] = 0;

Return Value

Name Type Description
returnedTargetString char * Contains a pointer to the modified target string.

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 6.0 and later

Was this information helpful?