gpt4 book ai didi

c++ - 视觉 C++ : how to pass pointer to array as parameter?

转载 作者:行者123 更新时间:2023-11-30 00:38:32 25 4
gpt4 key购买 nike

下面显示的代码是用Visual C++编写的

array<Byte>^ b = gcnew array <Byte> (filesize);
fs->Read(b,0,b->Length);
unsigned char *pb;
pb=(byte*)malloc(b->Length); //pb is unmanaged here.

for(int i=0;i<b->Length;i++)
{
*(pb+i)=InverseByte(b+i);
}

我想调用下面的函数来反转每个字节。我怎样才能做到这一点?我想对托管数组 b 的每个字节进行逆运算,并将其放入非托管数组 b。

unsigned char InverseByte(unsigned char* PbByte)
{
//something;
}

最佳答案

修复InverseByte的声明:

unsigned char InverseByte(unsigned char value)

所以你可以像这样使用它:

for (int i=0; i < b->Length; i++)
{
pb[i] = InverseByte(b[i]);
}

关于c++ - 视觉 C++ : how to pass pointer to array as parameter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10594548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com