Copies the initial nCount characters of sSource to sDest and returns sDest. If nCount is less than or equal to the length of sSource, no null character is appended to the copied string. If nCount is greater than the length of sSource, the destination string is padded with null characters up to length count. The behavior of Strncpy is undefined if the source string and the destination string overlap.
Kernel.bdh
Strncpy( out sDest : string, in sSource : string, in nCount : number): string;
The string actually copied. No special value indicates an error.
Parameter | Description |
---|---|
sDest | String to be overwritten. This parameter will contain the result of the copy operation |
sSource | Is copied into sDest |
nCount | Defines the number of characters to copy |
dcltrans transaction TStrncpy var sSource, sDest, sResult: string; begin sDest := "That is beautiful!"; sSource := "This is just a test!"; write("dest = "); write(sDest); writeln; write("source = "); write(sSource); writeln; sResult := Strncpy(sDest, sSource, 20); write("dest = "); write(sDest); writeln; write("result = "); write(sResult); writeln; end TStrncpy;
dest = That is beautiful! source = This is just a test! dest = This is just a test! result = This is just a test!