#define lengthOfArray(x) (sizeof(x) / sizeof(x[0]))
似乎在 main() 中给出了正确的答案,但在 array_set() 的 printf() 中。我错过了什么?
int* decValue2[BUF_SIZE] = {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
0x99, 0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
};
#define lengthOfArray(x) (sizeof(x) / sizeof(x[0]))
void array_set(int* y_dest, int* y_src, int arrayLength){ // arrays
int i = 0;
printf("lengthOfArray in function: %d \n", lengthOfArray(y_src));
// [TODO] check that y_dest has enough space
for (i=0;i<arrayLength; i++)
y_dest[i] = y_src[i];
//
}
// In main()
int y_int = 0;
int y_array[BUF_SIZE];
int_set_right( &y_int, 9876543);
array_set(y_array, decValue2, BUF_SIZE);
printf("lengthOfArray: %d \n", lengthOfArray(y_array));
printf("Value int :: %d \n",y_int);
int i = 0;
for (i=0;i<BUF_SIZE; i++)
printf("%x ", (0xff & y_array[i]));