memcpy Copies characters between buffers.void *memcpy( void *dest, const void *src, size_t count );Routine Required Header Compatibility memcpy <memory.h> or <string.h> ANSI, Win 95, Win NT For additional compatibility information, see Compatibility in the Introduction.LibrariesLIBC.LIB Single thread static library, retail version LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version Return Valuememcpy returns the value of dest.ParametersdestNew buffersrcBuffer to copy fromcountNumber of characters to copyResThe memcpy function copies count bytes of src to dest. If the source and destination overlap, this function does not ensure that the original source bytes in the overlapping region are copied before being overwritten. Use memmove to handle overlapping regions.Example/* MEMCPY.C: Illustrate overlapping copy: memmove * handles it correctly; memcpy does not. */#include <memory.h> #include <string.h> #include <stdio.h>char string1[60] = "The quick brown dog jumps over the lazy fox"; char string2[60] = "The quick brown fox jumps over the lazy dog"; /* 1 2 3 4 5 * 12345678901234567890123456789012345678901234567890 */void main( void ) { printf( "Function:\tmemcpy without overlap\n" ); printf( "Source:\t\t%s\n", string1 + 40 ); printf( "Destination:\t%s\n", string1 + 16 ); memcpy( string1 + 16, string1 + 40, 3 ); printf( "Result:\t\t%s\n", string1 ); printf( "Length:\t\t%d characters\n\n", strlen( string1 ) ); /* Restore string1 to original contents */ memcpy( string1 + 16, string2 + 40, 3 ); printf( "Function:\tmemmove with overlap\n" ); printf( "Source:\t\t%s\n", string2 + 4 ); printf( "Destination:\t%s\n", string2 + 10 ); memmove( string2 + 10, string2 + 4, 40 ); printf( "Result:\t\t%s\n", string2 ); printf( "Length:\t\t%d characters\n\n", strlen( string2 ) ); printf( "Function:\tmemcpy with overlap\n" ); printf( "Source:\t\t%s\n", string1 + 4 ); printf( "Destination:\t%s\n", string1 + 10 ); memcpy( string1 + 10, string1 + 4, 40 ); printf( "Result:\t\t%s\n", string1 ); printf( "Length:\t\t%d characters\n\n", strlen( string1 ) ); } OutputFunction: memcpy without overlap Source: fox Destination: dog jumps over the lazy fox Result: The quick brown fox jumps over the lazy fox Length: 43 charactersFunction: memmove with overlap Source: quick brown fox jumps over the lazy dog Destination: brown fox jumps over the lazy dog Result: The quick quick brown fox jumps over the lazy dog Length: 49 charactersFunction: memcpy with overlap Source: quick brown dog jumps over the lazy fox Destination: brown dog jumps over the lazy fox Result: The quick quick brown dog jumps over the lazy fox Length: 49 characters 是不是着一个?
如何给分: 管理,给分,添密码。ok 错误: 加个扩展C语句试试。
to 毒药:不是这个,你这个是讲memcpy,不是fmemcpyto 歪脚鸭: 怎么加扩展c语句,能不能具体点?我的源文件都是c文件
Copies characters between buffers.void *memcpy( void *dest, const void *src, size_t count );Routine Required Header Compatibility
memcpy <memory.h> or <string.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.LibrariesLIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Valuememcpy returns the value of dest.ParametersdestNew buffersrcBuffer to copy fromcountNumber of characters to copyResThe memcpy function copies count bytes of src to dest. If the source and destination overlap, this function does not ensure that the original source bytes in the overlapping region are copied before being overwritten. Use memmove to handle overlapping regions.Example/* MEMCPY.C: Illustrate overlapping copy: memmove
* handles it correctly; memcpy does not.
*/#include <memory.h>
#include <string.h>
#include <stdio.h>char string1[60] = "The quick brown dog jumps over the lazy fox";
char string2[60] = "The quick brown fox jumps over the lazy dog";
/* 1 2 3 4 5
* 12345678901234567890123456789012345678901234567890
*/void main( void )
{
printf( "Function:\tmemcpy without overlap\n" );
printf( "Source:\t\t%s\n", string1 + 40 );
printf( "Destination:\t%s\n", string1 + 16 );
memcpy( string1 + 16, string1 + 40, 3 );
printf( "Result:\t\t%s\n", string1 );
printf( "Length:\t\t%d characters\n\n", strlen( string1 ) ); /* Restore string1 to original contents */
memcpy( string1 + 16, string2 + 40, 3 ); printf( "Function:\tmemmove with overlap\n" );
printf( "Source:\t\t%s\n", string2 + 4 );
printf( "Destination:\t%s\n", string2 + 10 );
memmove( string2 + 10, string2 + 4, 40 );
printf( "Result:\t\t%s\n", string2 );
printf( "Length:\t\t%d characters\n\n", strlen( string2 ) ); printf( "Function:\tmemcpy with overlap\n" );
printf( "Source:\t\t%s\n", string1 + 4 );
printf( "Destination:\t%s\n", string1 + 10 );
memcpy( string1 + 10, string1 + 4, 40 );
printf( "Result:\t\t%s\n", string1 );
printf( "Length:\t\t%d characters\n\n", strlen( string1 ) );
}
OutputFunction: memcpy without overlap
Source: fox
Destination: dog jumps over the lazy fox
Result: The quick brown fox jumps over the lazy fox
Length: 43 charactersFunction: memmove with overlap
Source: quick brown fox jumps over the lazy dog
Destination: brown fox jumps over the lazy dog
Result: The quick quick brown fox jumps over the lazy dog
Length: 49 charactersFunction: memcpy with overlap
Source: quick brown dog jumps over the lazy fox
Destination: brown dog jumps over the lazy fox
Result: The quick quick brown dog jumps over the lazy fox
Length: 49 characters
是不是着一个?
管理,给分,添密码。ok
错误:
加个扩展C语句试试。