#포함하다 char *strncpy(char *dest, const char *str, size_t maxlen); |
strncpy 함수는 주어진 크기의 문자열을 다른 문자열로 복사합니다.
NULL 문자는 자동으로 추가되지 않으므로 필요한 경우 NULL 문자를 추가해야 합니다.
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
int main()
{
char s(100);
char s2() = "string copy";
strncpy(s, s2, 6);
s(6) = '\0';
printf("%s\n", s);
return 0;
}