so I'm pretty new to C and I'm a bit lost. I have an array of unsigned ints and I have a function that reverses the order of the array using pointers. in the function I pass 2 pointers, one for the start of the array and one for end of the array like so:
void swapedints(unsigned int *x, unsigned int *y) {
while (x != y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
x++;
y--;
}
}
When I'm calling the function in my main the starter pointer is defined as : &unsignedArray
and for the end of the array i used : endArray = (unsigned int *)(&unsignedArray +1) -1
When I pass this to the function I get a segmentation fault, can anybody explain why?
Update w/ correct solution:
void swapedints(unsigned int *x, unsigned int *y) {
while (x < y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
x++;
y--;
}
}
startPointer = unSignedarray endPointer = unSignedArray + array length -1