我尝试搜索此内容,因为我认为它必须在此处,但我无法弄清楚。
无论如何,如果我在C中有一个结构数组,例如:
struct structName array[];
我想交换array [i]和array [i + 1]的值怎么办?我在其他地方看到过int array [],但由于指针,它似乎无法正确应用。有什么帮助吗?
最佳答案
交换任何东西的方式都一样:
struct structName tmp = array[i];
array[i] = array[i+1];
array[i+1] = tmp;
关于c - 在C中的数组中交换对象,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10652089/