File: xstrncpy.c

package info (click to toggle)
cfdisk-utf8 2.11n-5%2B1
  • links: PTS
  • area: main
  • in suites: sarge, woody
  • size: 600 kB
  • ctags: 1,187
  • sloc: ansic: 10,113; sh: 586; makefile: 155
file content (10 lines) | stat: -rw-r--r-- 214 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
/* NUL-terminated version of strncpy() */
#include <string.h>
#include "xstrncpy.h"

/* caller guarantees n > 0 */
void
xstrncpy(char *dest, const char *src, size_t n) {
	strncpy(dest, src, n-1);
	dest[n-1] = 0;
}