CAPL Script

StrnCpyOff

Syntax

void strncpy_off(char dest[], long destOffset, char src[], long max);

Function

This function copiessrctodest.maxindicates the size ofdestin bytes. The function ensures that there is a terminating '\0'. Thus, a maximum of max-1-destOffset bytes are copied. Bytes are overwritten indeststarting atdestOffset.

Parameters

dest Destination buffer

destOffset

Offset in destination buffer

src

Source string

max

Is used to determine the maximum number of copied bytes.Must not be larger than the size ofdest. A maximum of max-1-destOffset bytes are copied.Ifsrcis shorter than that, bytes are only copied until a terminating '\0' is encountered.

Return Values

char s[6] = "Hello";strncpy_off(s, 1, "e", elcount(s)); // s: He

strlen | strncat | strncmp | strncpy