/*-----------------------------------------------------------*/ /* Program chapter6_3 */ /* */ /* This program demonstrates the relationship between */ /* variables, addresses, and pointers. */ #include int main(void) { /* Declare and initialize variables. */ int a=1, b=2, *ptr=&a; /* Print the variable and pointer contents. */ printf("a = %d; address of a = %u \n",a,(unsigned int)&a); printf("b = %d; address of b = %u \n",b,(unsigned int)&b); printf("ptr = %u; address of ptr = %u \n",(unsigned int)ptr,(unsigned int)&ptr); printf("ptr points to the value %d \n",*ptr); /* Exit program. */ return 0; } /*------------------------------------------------------------*/