strcpy strncpy in c example illustration
The C library function char *strcpy(char *dest, const char *src) and char *strncpy(char *dest, const char *src, size_t n) are used to copy characters from src string to dest string.
strcpy() function copies the source string pointed to by src, including the terminating null character ('\0'), to the destination string pointed to by dest. The destination string dest must be large enough to hold the entire content of source string including null characters.
strncpy() function copies upto n bytes of source string src to destination string dest. If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated. Also if length of the source string is less than n characters, remaining no of charatcers will be padded as null bytes in the destination string.
strcpy, strncpy header file
The functions strcpy and strncpy are included in the C standard library header file string.h
To Read Full Article
You need to subscribe & logged in
Want to contribute or ask a new article? Write and upload your article information here