SourcePoint Intel Help

Table of Contents

strncpy

Copies a portion of one string into another.

Syntax

strncpy(string-expr1, string-expr2, expr)

Where:

string-expr1

specifies an nstring variable.

string-expr2

specifies an nstring variable or a quoted string constant.

expr

specifies a number or an expression of type int4 that specifies the maximum number of characters to copy.

Discussion

The strncpy command copies the specified maximum number of characters (expr) from the second string (string-expr2) to the first string (string-expr1). Copying stops when a null terminating character is copied or when the number of characters specified have been copied. If expr is greater than the length of string-expr2, the string-expr1 resulting from the copy is string-expr2.

Example

Command input:

define nstring month = "October"
define nstring date
strncpy(date, month, 3)
date

Result:

"Oct"

Related Topics: