我正在用 C++/CX 编写一个 Windows 手机应用程序。该函数尝试将输入数组异步复制到输出数组:
IAsyncAction CopyAsync(const Platform::Array<byte, 1>^ input, Platform::WriteOnlyArray<byte, 1>^ output)
{
byte *inputData = input->Data;
byte *outputData = output->Data;
int byteCount = input->Length;
// if I put it here, there is no error
//memcpy_s(outputData, byteCount, inputData, byteCount);
return concurrency::create_async([&]() -> void {
memcpy_s(outputData, byteCount, inputData, byteCount); // access violation exception
return;
});
}
此函数编译但无法正确运行并产生“访问冲突异常”。如何修改输出数组中的值?