我正在尝试访问内存访问的值,但是在打印输出时,我一直在获取地址。
char c[16];
char copyArray(unsigned char* state, unsigned char* key)
{
for (int i = 0; i < 16; i++)
{
state[i] ^= key[i];
// c[i] = state[i]; // this gave me the address
printf("%02x", state[i]);
}
printf("\n");
memcpy (c, state,16);
for (int i = 0; i < 16; ++i)
{
printf("%02d\n",c[i] );
}
printf("\n");
}
此功能在另一个功能中执行10次。我想要实现的是存储上次执行的值而不是地址
答案 0 :(得分:0)
谢谢大家!
现在解决了。我将c数组设为无符号,就解决了问题
unsigned char c[16];
char copyArray(unsigned char* state, unsigned char* key)
{
for (int i = 0; i < 16; i++)
{
state[i] ^= key[i];
printf("%02x", state[i]);
}
printf("\n");
memcpy (c, state,16);
for (int i = 0; i < 16; ++i)
{
printf("%02x\n",c[i] );
}
printf("\n");
}