C - Write program to point char point to three different char variables

Requirements

Declare three char variables and initialized all.

First, pointer p is initialized to the address of a char variable.

Second, the * (asterisk) is used to peek at the value stored at that address.

The *p variable represents that value as a char inside the putchar() function.

Repeat that operation for char variables b and c.

Demo

#include <stdio.h> 

int main() //from  w  ww . j av a2s . com
{ 
   char a,b,c; 
   char *p; 

   a = 'A'; b = 'B'; c = 'C'; 

   printf("Know your "); 
   p = &a;                 // Initialize 
   putchar(*p);            //  Use 
   p = &b;                 // Initialize 
   putchar(*p);            //  Use 
   p = &c;                 // Initialize 
   putchar(*p);            //  Use 
   printf("s\n"); 

   return(0); 
}

Result

Related Example