だから私は unsigned char * を返すメソッドを持っています
unsigned char* someMethod(num)
unsigned short num;
{
//do some stuff with num and change values of a
unsigned char * a = (unsigned char*) malloc(4);
printf("a0 is %x\n",a[0]);
printf("a1 is %x\n",a[1]);
printf("a2 is %x\n",a[2]);
printf("a3 is %x\n",a[3]);
return a;
}
someMethod(128) を呼び出したとき:
unsigned char* s = someMethod(128);
printf("s0 is %x\n",s[0]);
printf("s1 is %x\n",s[1]);
printf("s2 is %x\n",s[2]);
printf("s3 is %x\n",s[3]);
それは印刷されます
a0 is 30
a1 is 1
a2 is 31
a3 is 30
s0 is 30
s1 is 14
s2 is ffffff9d
s3 is 0
s = someMethod(128) を割り当てるので、まったく意味がありません。a と s が同じ値であってはいけませんか?!? どんな助けでも大歓迎です。ありがとうございました!