C#实现memmove函数功能
下面是一个C#实现memmove函数功能的代码示例:
using System;
using System.Runtime.InteropServices;
class Program
{
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
public static extern IntPtr memmove(IntPtr dest, IntPtr src, int count);
static void Main(string[] args)
{
byte[] src = new byte[] { 1, 2, 3, 4, 5 };
byte[] dest = new byte[5];
GCHandle srcHandle = GCHandle.Alloc(src, GCHandleType.Pinned);
GCHandle destHandle = GCHandle.Alloc(dest, GCHandleType.Pinned);
IntPtr srcPtr = srcHandle.AddrOfPinnedObject();
IntPtr destPtr = destHandle.AddrOfPinnedObject();
memmove(destPtr, srcPtr, src.Length);
srcHandle.Free(