我在java中有以下代碼,我需要將其轉換爲C++以便能夠對unsigned int進行編碼。encoding unsigned int
public static int enc_uint32be(int i, byte[] dst, int di) {
dst[di++] = (byte)((i >> 24) & 0xFF);
dst[di++] = (byte)((i >> 16) & 0xFF);
dst[di++] = (byte)((i >> 8) & 0xFF);
dst[di] = (byte)(i & 0xFF);
return 4;
}
我是java的新手。我相信這個論壇上的幾位專家都知道這兩種語言 - 有人可以幫我翻譯。
謝謝,這是股票價格,所以我相信字符應該工作。我相信當我嘗試轉換更多代碼時,我會遇到更多問題。 – user1155299
您可能對'typedef unsigned char byte;'感興趣,這可以稍微緩解一些轉換。 –
@ MooingDuck,謝謝,這是一個很好的建議 – user1155299