Tutorials Point


  Learning C
  C Function References
  C Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     About TP     Advertising  

C - memcpy function

previous

Synopsis:

#include <stdio.h>

void* memcpy(void* s, const void* ct, int n);

Description:

The memcpy function copies n bytes from ct to s. If these memory buffers overlap, the memcpy function cannot guarantee that bytes in ct are copied to s before being overwritten. If these buffers do overlap, use the memmove function.

Return Value

The memcpy function returns dest.

Example

#include <stdio.h>

int main() {
  char src [100] = "Copy this string to dst1";
  char dst [100];
  char *p;

  p = memcpy (dst, src, sizeof (dst));
  printf ("dst = \"%s\"\n", p);
}

It will proiduce following result:

dst = "Copy this string to dst1"


previous Printer Friendly

Advertisements


  

Advertisements