Programming Reference/Librarys
Question & Answer
Q&A is closed
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 <stdio.h> /* including standard library */ //#include <windows.h> /* uncomment this for Windows */ #include <string.h> 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