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

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/string.h/memcpy.txt · Last modified: 2024/02/16 01:06 (external edit)

Impressum Datenschutz