User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:string.h:memmove

memmove

    #include <stdlib.h>
    void *memmove(void *str1, const void *str2, size_t n);

str1: target memory block (at least size bytes in size)
str2: source memory block (at least size bytes in size)
n: number of bytes to be copied (The type size_t corresponds usually int))

memmove C Sourcecode Example

/* 
 * memmove example code
 * http://code-reference.com/c/string.h/memmove
 */
#include <stdio.h>
#include <string.h>
 
int main ( void )
{
 
  char str[100] = "memmove example"; 
  char str2[15];  
  int n;  
 
  n = strlen(str);   /* bytes to copy */
 
  memmove( str2, str, n );
 
  printf("\"move\" string str to str2 : ");
  puts( str2 );
 
  printf("move str 40 bytes further : ");
  memmove(str+40, str, 15);
  puts(str);
 
  printf("move str 14 bytes further : ");
  memmove(str+8, str, 15);
  puts(str);
 
  return 0;
}

output of memmove c example

  user@host:~$ ./memmove 
  "move" string str to str2 : memmove example
  move str 40 bytes further : memmove example
  move str 14 bytes further : memmove memmove example

on the occasion of the current invasion of Russia in Ukraine

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

Impressum Datenschutz