C Language strcpy,memcpy,memmove,memccpy function

Source: Internet
Author: User

1. Prototype: extern char *strcpy (char *dest,char *src);

Usage: #include <string.h>

function: Copy the null-terminated string from SRC to the array referred to by Dest.

Description: The memory areas referred to by SRC and dest cannot overlap and dest must have sufficient space to accommodate the SRC string.

Returns a pointer to the dest.

2. Prototype: extern void *memcpy (void *dest, void *src, unsigned int count);

Usage: #include <string.h>

Function: the memory area referred to by SRC is copied from count bytes to the memory area of Dest.

Description: The memory area referred to by SRC and dest cannot overlap, and the function returns a pointer to Dest.

3. Prototype: extern void *memmove (void *dest, const void *SRC, unsigned int count);

Usage: #include <string.h>

Function: the memory area referred to by SRC is copied from count bytes to the memory area of Dest.

Description: The memory areas referred to by SRC and dest can overlap, but the SRC content will be changed after copying. function returns a pointer to Dest

4. Prototype: extern void *memccpy (void *dest, void *src, unsigned char ch, unsigned int count);

Usage: #include <string.h>

Function: the memory area referred to by SRC is not more than count bytes to the memory area referred to by dest, and if the character ch is encountered, it stops copying.

Description: Returns a pointer to the first character after the character CH, or null if no ch is present in the first n bytes of SRC. CH is copied.

Note: Memory overlap issues.

C Language strcpy,memcpy,memmove,memccpy function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.