Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRNRPT.C

Output of file : STRNRPT.C contained in archive : ECSTR.ZIP
/* File : strnrpt.c
Author : Richard A. O'Keefe.
Updated: 20 April 1984
Defines: strnrpt()

strnrpt(dst, n, src, k) "RePeaTs" the string src into dst k times,
but will truncate the result at n characters if necessary. E.g.
strnrpt(dst, 7, "hack ", 2) will move "hack ha" to dst WITHOUT the
closing NUL. The result is the number of characters moved, not
counting the closing NUL. Equivalent to strrpt-ing into an infinite
buffer and then strnmov-ing the result.

#include "strings.h"

int strnrpt(dst, n, src, k)
register char *dst;
register int n;
char *src;
int k;
char *save;

for (save = dst; --k >= 0; dst--) {
register char *p;
for (p = src; ; ) {
if (--n < 0) return dst-save;
if (!(*dst++ = *p++)) break;
return dst-save;

  3 Responses to “Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRNRPT.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: