相关疑难解决方法(0)

C++ int到byte数组

我在我的java代码中有这个方法,它返回给定int的字节数组:

private static byte[] intToBytes(int paramInt)
{
     byte[] arrayOfByte = new byte[4];
     ByteBuffer localByteBuffer = ByteBuffer.allocate(4);
     localByteBuffer.putInt(paramInt);
     for (int i = 0; i < 4; i++)
         arrayOfByte[(3 - i)] = localByteBuffer.array()[i];
     return arrayOfByte;
}
Run Code Online (Sandbox Code Playgroud)

有人可以给我提示如何将该方法转换为C++?

c++ arrays int byte

26
推荐指数
7
解决办法
10万
查看次数

标签 统计

arrays ×1

byte ×1

c++ ×1

int ×1