1#include <assert.h>2#include <stdio.h>3#include <string.h>45#define SIZ 667/*8output:9testing10test111test212test313done14end:15*/1617int18main()19{20 char *s, buf[SIZ];2122 puts("testing");2324 puts("test1");25 memset(buf, '0', SIZ);26 s = strncpy(buf, "abc", sizeof(buf));27 assert(s == buf);28 assert(!memcmp(s, (char[SIZ]) {"abc"}, sizeof(buf)));2930 puts("test2");31 memset(buf, '0', SIZ);32 s = strncpy(buf, "", sizeof(buf));33 assert(s == buf);34 assert(!memcmp(s, (char[SIZ]) {'\0'}, sizeof(buf)));3536 puts("test3");37 memset(buf, '0', SIZ);38 s = strncpy(buf, "", 1);39 assert(s == buf);40 assert(!memcmp(s,41 (char[SIZ]) {'\0', '0', '0', '0', '0', '0'},42 sizeof(buf)));4344 puts("done");4546 return 0;47}