0
在C中交換數組的最佳做法是什麼?交換數組引用C
我得到了以下的用例:
void func1() {
uint32_t a[2] = {0x00000001,0x40000000};
uint32_t t = 2;
do_some_magic(&t, a);
work_with_modefied(t,a);
}
void do_some_magic(uint_32_t *t,*a){
//while being a magician
uint32_t *out;
out = (uint32_t *) malloc((*t+1)*4);
//modify a[i] and store in out[i];
//some other work
//the tricky part
*t++; // works excellent
// a = out wouldn't work
// *a = *out wouldn't work
}
很難說出你實際想要做什麼。你能澄清一下你的問題嗎? –
沒有意義。 –
這是一個不能重寫數組的常量對象。它會用一個指針來代替這個目的。 – BLUEPIXY