How to use memmove() function to copy N bytes from source to destination in C

3 Answers

0 votes
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[] = "abc def ghi jkl";
	char s1[32];
  
	memmove(s1, s + 4, 3 * sizeof(char));
	puts(s);
	puts(s1);

    return 0;
}
  
    
/*
      
run:

abc def ghi jkl
def

*/

 



answered Jan 31, 2016 by avibootz
0 votes
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[] = "abc def ghi jkl";
  
	memmove(s, s + 4, 3 * sizeof(char));
	puts(s);

    return 0;
}
  
    
/*
      
run:

def def ghi jkl

*/

 



answered Jan 31, 2016 by avibootz
0 votes
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[256] = "Programming is complete fun";
  
	memmove(s + 24, s + 15, 12 * sizeof(char));
	puts(s);

    return 0;
}
  
    
/*
      
run:

Programming is complete complete fun

*/

 



answered Jan 31, 2016 by avibootz

Related questions

...