strncopy()

strncopy()

Description

Create a copy of a defined length string.

Syntax

strncopy(dest[], source[], length, sizeofdest);

Parameters

Variable

Input

Variable

Input

dest[]

The buffer to store the copy of the string string in.

source[]

The string to copy, this may be a packed or an unpacked string.

length

Number of characters to be copied from source.

sizeofdest

Maximum length of destination string.

Returns

Returns length of copied data bytes.

Function call example

example of strncopy
new copy_array[25]=''this will be copied''; new duplicate_array[25]; main(){ strncopy(duplicate_array,copy_array, 10, 25); // copy_array will be placed into duplicate_array, but only 10 characters while(1){ Delay(1000); // Delay 1 sec. } }

Notes and Warnings

This function copies a string from source to dest. If the source string is a packed string, the destination will be packed too; likewise, if the source string is unpacked, the destination will be unpacked too. See functions strpack and strunpack to convert between packed and unpacked strings.