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