ProgIntro

Pointers

Introduction

Pointer Variable Definitions and Initialization

 int *countPtr, count;

Pointer Operators

The & or address operator is a unary operator that returns the address of its operand. For example

int y =5
int *yPtr;

yPtr = &y

The third statement assigns the address of the variable y to pointer variable yPtr.


#include<stdio.h>
int main (void)
{
	int a;
	int *aPtr;

	a = 7;
	aPtr = &a;
	printf("The address of a is %p \nThe value of aPtr is %p", &a, aPtr);
	printf("The value of a is %d \nThe value of *aPtr is %d", a, *aPtr);
	printf("\n\nShowing that * and & are compelements of each other\n&*aPtr = %p\n*&aPtr = %p\n", &*aPtr, *&aPtr);
 
  return 0;
}