returnValue = Integer.toHexString(accumulator).toUpperCase();
for (i=returnValue.length(); i<4; i++)
returnValue = '0' + returnValue;
C++无法获得数组的长度啊
------解决方案--------------------
用C写的。
- C/C++ code
char* g(unsigned int a) { char k[] = "0123456789ABCDEF"; char r[sizeof (a)*2]; int i = 0; while (a != 0) { r[i++] = k[a % 16]; a /= 16; } while (i < 4) { r[i++] = '0'; } char* t = malloc(i + 1); int j = 0; while (j < i) { t[j++] = r[i - 1 - j]; } t[i] = 0; return t;}