0

我的问题是我有java方法我需要转换这个目标我正在尝试这个但它返回零

-(char *)intToByteArray:(char *)data{
int iii13=((int)((data[0]>>24),(data[1] >>16) ,(data[2] >>8),(data[3]>>0)));
char* where = (char*)malloc(10);
where[0] = *((char*)(&iii13) + 0);
where[1] = *((char*)(&iii13) + 1);
where[2] = *((char*)(&iii13) + 2);
where[3] = *((char*)(&iii13) + 3);
// 0
// char *www11 = (char *)www13; 
return where;  
}
<=====================Java Code================> is below

public static final byte[] intToByteArray(int value) {
    return new byte[] {
            (byte)(value >>> 24),
            (byte)(value >>> 16),
            (byte)(value >>> 8),
            (byte)value};
}

我想返回 char本身,所以任何人都可以建议我正确的方法

4

1 回答 1

0

你的意思是?

 // assuming you have a little endian processor.
 long* where = (long*) malloc(4);
 *where = value;
 return (char *) where;
于 2012-08-06T10:52:29.770 回答