answersLogoWhite

0


Best Answer

Its similar to typing without insert key ON and OFF

str1="strings are good");

memmove(str1+8,str1+11,4);

returns------ strings are are good

memcpy(str+8,str1+11,4)

returns------ strings are read

memcpy - just copies from source to destination.

memmove - copies from source to destination if buffers overlap, every character is read before another character is written to the same location

memcpy() copies the bytes of data between memory blocks. If the block of memory overlaps, the function might not work properly. Use memmove() to deal with overlapping memory blocks.

memmove() is very much like memcpy() but very flexible as it handles overlapping of memory blocks.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

16y ago

hi frends, void *memmove(void *DST, const void *SRC, size_t LENGTH); This function moves LENGTH characters from the block of memory start-

ing at `*SRC' to the memory starting at `*DST'. `memmove' reproduces

the characters correctly at `*DST' even if the two areas overlap.

void* memcpy(void *OUT, const void *IN, size_t N);

This function copies N bytes from the memory region pointed to by IN

to the memory region pointed to by OUT. If the regions overlap, the behavior is undefined.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

memmove ensure that the original source bytes in an overlapping region are copied before being overwritten.

memcpy's behaviour is undefined if the source and the destination overlap.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is difference between memcpy and memmove?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between the functions memmove and memcpy?

memmove handles the case where the source memory and destination memory overlap.


Which function is the correct choice for moving blocks of binary data that are of arbitrary size and position in memory?

memcpy()


How would you use the functions memcpy memset memmove?

The memset() FunctionTo set all the bytes in a block of memory to a particular value, use memset(). The function prototype is void * memset(void *dest, int c, size_t count); The argument dest points to the block of memory. c is the value to set, and count is the number of bytes, starting at dest, to be set. Note that while c is a type int, it is treated as a type char. In other words, only the low-order byte is used, and you can specify values of c only in the range 0 through 255.Use memset() to initialize a block of memory to a specified value. Because this function can use only a type char as the initialization value, it is not useful for working with blocks of data types other than type char, except when you want to initialize to 0. In other words, it wouldn't be efficient to use memset() to initialize an array of type int to the value 99, but you could initialize all array elements to the value 0. memset() will be demonstrated in program below.The memcpy() Functionmemcpy() copies bytes of data between memory blocks, sometimes called buffers. This function doesn't care about the type of data being copied--it simply makes an exact byte-for-byte copy. The function prototype is void *memcpy(void *dest, void *src, size_t count); The arguments dest and src point to the destination and source memory blocks, respectively. count specifies the number of bytes to be copied. The return value is dest. If the two blocks of memory overlap, the function might not operate properly--some of the data in src might be overwritten before being copied. Use the memmove() function, discussed next, to handle overlapping memory blocks. memcpy() will be demonstrated in program below.The memmove() Functionmemmove() is very much like memcpy(), copying a specified number of bytes from one memory block to another. It's more flexible, however, because it can handle overlapping memory blocks properly. Because memmove() can do everything memcpy() can do with the added flexibility of dealing with overlapping blocks, you rarely, if ever, should have a reason to use memcpy(). The prototype is void *memmove(void *dest, void *src, size_t count); dest and src point to the destination and source memory blocks, and count specifies the number of bytes to be copied. The return value is dest. If the blocks overlap, this function ensures that the source data in the overlapped region is copied before being overwritten. Sample program below demonstrates memset(), memcpy(), and memmove().


What are the differences between memcpy vs strcpy?

memcpy is general purpose copy. and strcpy is specific for string copying. strcpy will copy the source string to destination string and terminate it with '\0' character but memcpy takes extra argument which specifies the number of bytes to copy.memcpy will not handle copying of overlapping memory. use memove instead.


What is the memcpy library used for in computer programming?

The memcpy library is used in computer programming to copy the value of numbers from a source to the memory block destination. Memcpy is frequently used in the C++ programming language.


What is syntax of memcpy?

memcpy function is used to copy memory area. Syntax ------ void *memcpy(void *dest, const void *src, size_t n); *dest is a destination string. *src is a source string. n is a number of characters to be copied from source string. Example: #include #include main() { char src[]="Hello World"; char des[10]; memcpy(des,src,5); printf("des:%s\n",des); //It will contain the string "Hello". }


What is better strcpy or memcpy?

They do different things, so they are uncomparable.PS: strcpy can be implemented with strlen+memcpy:char *strcpy (char *dest, const char *src){size_t len;len= strlen (src);memcpy (dest, src, len);return dest;}


Code to implement memcpy in c?

unsigned char * memcpy(unsigned char * s1, unsigned char * s2, long size) { long ix; s1= (char *)malloc(sizeof(strlen(s2))); for(ix=0; ix < size; ix++) s1[ix] = s2[ix]; return s1; }


To copy two strings using strcpy?

Using strcpy and strcat. Or sprintf. Or strlen+memcpy. There are more than solutions.


What is difference between as on and as at?

difference between as on and as at


How is a bitwise copy created in c plus plus?

You could just use memcpy(3), using sizeof() to get the object size.


What are the differences between California and Florida?

What is the difference between Florida and California What is the difference between Florida and California