Array Echo With Compound Increments
/* * Read some integers into an array, then echo them, using pointers. */ #include <iostream> using namespace std; const int ARRMAX = 100; main() { /* Read them in. Use an body-less loop which increments in the test. */ int arr[ARRMAX]; /* Array of numbers. */ int *scan = arr; cout << "Enter some integers: " << endl; while(cin >> *scan++); int *end = scan - 1; // scan is incremented on fail. /* Print them back out again. */ cout << "===============" << endl; for(scan = arr; scan < end;) cout << *scan++ << " "; cout << endl; }

This uses fancier increments. Note that the increment is higher precedence, so *scan++ means *(scan++).