Register | Sing In

New posts

Stacks in C programming Linked Lists in C programming File Input/Output in C programming Check prime numbers in C Programming C Programming Enumeration C Programming Union

Archives

2013-10 2013-09 2013-08

Function memmove in C programming

September 18, 2013 Posted by: GPA Views: 26746 0 comments

Problem

 How to implement memmove() function in C programming.

Solution

In this section, you will learn how to implement memmove() function of header file <string.h>.

Declaration:

void *memmove( void * firstArgument, const void * secondArgument, size_t n );

This function, like memcpy, copies a specified number (n) of data from secondArgument into firstArgument. But it copies from the second argument into a temporary character array, then it copies from the temporary array into the first argument. It allows to copy characters from one part of a string into another part of the same string.

Example:



#include <stdio.h>
#include <stdlib.h>
#include <string.h>//for function memmove
//main function
int main(int argc, char *argv[])
{
char firstArgument[]="Peter loves Sara";
printf("globalproganswer.com\n");
printf("\nfirstArgument before using memmove() is: %s", firstArgument );
printf("\nfirstArgument after using memmove() is: %s",memmove(firstArgument,&firstArgument[11],5));
printf("\n");//new line
system("PAUSE");//delay
return 0;
}

Output

Function memmove

Download this example

0 Comments...

Leave a Reply

Please, Sing In to leave a Reply for this material.



Online Chat

LiveZilla Live Help

Popular posts

Function strtok in C programming Check prime numbers in C Programming C Programming Union Linked Lists in C programming File Input/Output in C programming C Programming Enumeration

RSS-subscribe

New materials

Subscribe