strcpy strncpy in c example illustration



Share

Description
    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

Subscribe


Want to contribute or ask a new article? Write and upload your article information .
Share

 Articles

 C Programming

 Linux Software

 Search Code Snippets

 Popular C search examples

 Popular C search MCQs

 Test your skills:online tests

 C Programming

 Python Programming

 Linux Software

 Quantitative Aptitude

 Embedded System Software