User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:string.h:memcpy

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 <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
advertising
c/string.h/memcpy.txt · Last modified: 2013/01/22 22:02 (external edit)

Impressum Datenschutz