Printing pointer addresses

This is what I have so far. I don't really know how to print the address of value1 though. Can someone show me how?

#include <iostream>
using namespace std;

int main()
{
int value1 = 2000;
int value2;

int *iptr;// DECLARE the variable iPtr to be a pointer to an
// object of type int

iptr = &value1;// ASSIGN the address of variable value1 to pointer
// variable iPtr

printf("Value of object pointed to by iPtr is %d\n",*iptr);// PRINT the value of the object pointed to by iPtr

value2 = *iptr;// ASSIGN the value of the object pointed to by iPtr
// to value2

printf("Value of value2 is %d\n",value2);// PRINT the value of value2

printf("Address of value1 is %d\n",value1);// PRINT the address of value1

printf("Address stored in iPtr is %d\n",iptr);// Print the address stored in iPtr


}
Use the reference operator on the variable.

&value1
Thanks go it!
Topic archived. No new replies allowed.