summaryrefslogtreecommitdiff
path: root/com32/lib/stpncpy.c
blob: 0537a56c3147ca3bcfe6c1f7c034c4540dcb86c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * stpncpy.c
 *
 * stpncpy()
 */

#include <string.h>

char *stpncpy(char *dst, const char *src, size_t n)
{
    char *q = dst;
    const char *p = src;
    char ch;

    while (n--) {
	*q = ch = *p++;
	if (!ch)
	    break;
	q++;
    }

    return q;
}