C++递增指针

#include <iostream>

using namespace std;
const int MAX = 3;

int main () {
   int  var[MAX] = {10, 100, 200};
   int  *ptr;

   // let us have array address in pointer.
   ptr = var;

   for (int i = 0; i < MAX; i++) {
      cout << Address of var[ << i << ] = ;
      cout << ptr << endl;

      cout << Value of var[ << i << ] = ;
      cout << *ptr << endl;

      // point to the next location
      ptr++;
   }

   return 0;
}

相关文章

#include <iostream> using namespace std; int mai...
#include <iostream> using namespace std; int mai...
// #include <iostream> using namespace std; int...
#include <iostream> #include <string> using...
#include <iostream> #include <cstring> usin...
#include <iostream> using namespace std; int mai...