Tuesday 17 January 2012

C - memcpy function

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"

No comments:

Post a Comment

host gator coupon