This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/stncpy_s.c

21 lines
473 B
C
Raw Normal View History

#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>
#include <string.h>
void main( void )
{
char buffer[15];
strncpy_s( buffer, sizeof( buffer ), "abcdefg", 10 );
printf( "%s\n", buffer );
strncpy_s( buffer, sizeof( buffer ), "1234567", 6 );
printf( "%s\n", buffer );
strncpy_s( buffer, sizeof( buffer ), "abcdefg", 3 );
printf( "%s\n", buffer );
strncpy_s( buffer, sizeof( buffer ), "*******", 0 );
printf( "%s\n", buffer );
}