I have a function which takes a pointer to an array (so an int**). In this function, I'd like to call swap(int*, int*) to swap the location of two of the elements in the array. What is the syntax in C for swapping these two elements?
Here's an example of what I'm looking for:
int* do_something(int** arr) {
// assume i and j are valid locations in the array
swap(&arr[i], &arr[j]); // what should this line be?
}
// this function works fine, no changes needed
void swap(int* a, int* b) {
int temp = *a;
*a = *b;
*b = temp;
}
&symbolsdo_something.double* a;. Though, on the other hand, saying "pointer to a pointer to an integer" is a bit wordy.