Differentiate the memory address and the stored data of the C variables in C pointer programming

 

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows 2003 Server Standard Edition

Header file: Standard

Additional library: none/default

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 (/TC)

Other info:

To do: Differentiate the memory address and the actual stored data location in C pointer programming

To show: A very simple pointer variable in C program

 

 

// Simple pointer variable

// Differentiate the memory address and the actual stored data location for pointer variables

#include <stdio.h>

 

int main(void)

{

int *m;

int location = 200;

m = &location;

 

printf("The data, *m = %d\n",*m);

printf("The address where the data is stored, m = %p\n", m);

 

return 0;

}

 

Output example:

 

The data, *m = 200

The address where the data is stored, m = 0012FF54

Press any key to continue . . .

 

 

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