Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • memcpy() in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 641
    Comment on it


    This method as the name suggest memcpy() i.e memory copy is used to copy a number of bytes i.e a block of memory from one location to another location.

    Syntax of memcpy():

    void * memcpy(void *to, const void *from, size_t numBytes);

    Program to demonstrate memcpy() method in C:

    /* A C program to demonstrate working of memcpy */
    #include <stdio.h>
    #include <string.h>
    int main ()
      char str1[] = "Demo";  
      char str2[] = "First";  
      puts("str1 before memcpy ");
      /* Copies contents of str2 to sr1 */
      memcpy (str1, str2, sizeof(str2));
      puts("\nstr1 after memcpy ");
      return 0;


    str1 before memcpy


    str1 after memcpy


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: