Printing the address of the stored char pointer variable C++ code example

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info: none

To do: Displaying the address of the stored char pointer variable in C++ programming

To show: How to print the address stored pointer variable in C++ programming

 

// printing the address of the stored char pointer variable

#include <iostream>

using namespace std;

 

int main(void)

{

// declare the char pointer that point to a string

char * string = "pointer testing";

 

cout<<"\nThe string is: "<<string

<<"\nValue of (void *) string, the address is: "

<<(void *)string <<endl;

 

return 0;

}

 

Output example:

 

The string is: pointer testing

Value of (void *) string, the address is: 00416744

Press any key to continue . . .

 

 

C and C++ Programming Resources | C & C++ Code Example Index