arraysaspointers - CPP #Include Using Namespace Int

You might also like

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 1

//ArraysAsPointers.

cpp
#include <iostream>
using namespace std;
int main()
{
int b[3][2];
cout << sizeof(b) << endl;
cout << sizeof(b + 0) << endl;
cout << sizeof(*(b + 0)) << endl;
// the next line prints 0012FF68
cout << "The address of b is: " << b << endl;
cout << "The address of b+1 is: " << b + 1 << endl;
cout << "The address of &b is: " << &b << endl;
cout << "The address of &b+1 is: " << &b + 1 << endl << endl;
return 0;
}
/** Output on Venus from a run of this program
/home/faculty/glandau/2016Summer/211> ./a.out
24 // size of the array 3*2*4 ( sizeof(int) = 4 )
8 // size of an address(pointer)on venus (64 bit machine) is 8 bytes

8 // Each row has 2 int(s) 2*4 bytes ( first ( end each ) row has 8 bytes )
The address of b is: 0x7ffea7f5b5d0

// address of the array

The address of b+1 is: 0x7ffea7f5b5d8 // b + sizeof(*(b+0)) (address of second row)


The address of &b is: 0x7ffea7f5b5d0

// b and &b mean the same

The address of &b+1 is: 0x7ffea7f5b5e8 // b + size(b)

*******************************************/

You might also like