Kayoss: Array members must be in an increasing order, but your program is not showing that -- it is showing the address of some pointers that hold the address you want.
Code:
#include <iostream>
using namespace std;
int main()
{
int array[2] = {2,3};
cout << &array[0] << ' ' << array[0] << '\n';
cout << &array[1] << ' ' << array[1] << '\n';
return 0;
}
/* my output
0012FF84 2
0012FF88 3
*/
[edit]
Code:
#include <iostream>
using namespace std;
void swap( int * const element1PTR, int * const element2PTR )
{
int hold = *element1PTR;
*element1PTR = *element2PTR;
*element2PTR = hold;
}
int main()
{
int array[2] = {2,3};
int *arrayPTR = array;
int *arrayPTR1 = &array[1];
cout << *arrayPTR << " " << arrayPTR << endl; // first element and address
cout << *arrayPTR1 << " " << arrayPTR1 << endl; // second element and address
cout << "SWAP" << endl;
// the following code swaps elements in array, defined after function main
swap( &array[0], &array[0 + 1] );
cout << *arrayPTR << " " << arrayPTR << endl;
cout << *arrayPTR1 << " " << arrayPTR1 << endl;
return 0;
}
/* my output
2 0012FF84
3 0012FF88
SWAP
3 0012FF84
2 0012FF88
*/