#include <stdio.h>
#define STR_BUF 10000
#define STR_MATCH 7
void mystrncpy(char* s, char* t, int n) {
while(*s++ = *t++ && n-- > 0);
}
int main() {
int result;
char str_s[STR_BUF] = "not so long test string";
char buf_1[STR_BUF];
mystrncpy(buf_1, str_s, STR_MATCH);
printf ("buf_1 (mystrncpy, 7 chars): %s\n", buf_1);
return 0;
}
実行したところ、何も起こりませんでした
ian@ubuntu:~/tmp$ gcc myncpy.c -o myn&&./myn
buf_1 (mystrncpy, 7chars):