strcpy 會copy '\0'
阿新 • • 發佈:2018-12-15
SYNOPSIS
#include <string.h>
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);
The strcpy() function copies the string pointed to by src, including the terminating null byte
('\0') ,
to the buffer pointed to by dest. The strings may not overlap, and the destination string
dest must be large enough to receive the copy.
The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If
there is no null byte among the first n bytes of src, the string placed in dest will not be null
terminated.
#include <string.h>
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);
The strcpy() function copies the string pointed to by src, including the terminating null byte
('\0')
dest must be large enough to receive the copy.
The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If
there is no null byte among the first n bytes of src, the string placed in dest will not be null
terminated.