{{keywords>wiki library source code example reference}}
===== memcpy =====
void *memcpy(void *str1, const void *str2, size_t n);
Copy a string into another variable
important here is to give the size of the string
#include /* including standard library */
//#include /* uncomment this for Windows */
#include
int main ( void )
{
char source[20]="Test 1234 ! :D";
char dest[20];
memcpy (dest,source,strlen(source)+1);
printf ("Value of Destination is %s\n",dest);
return 0;
}
output:
user@host:~$ ./memcpy
Value of Destination is Test 1234 ! :D