C++ Program to print address of character

Simple C Program to print address of character.
 
/* C++ Program to print address of character */
#include<iostream>
using namespace std;
int main()
{
 char ch;
 cout<<"Enter a character: ";
 cin>>ch;
 cout<<"Address of character "<<(void *)&ch;
 return 0;
}
 

Another C++ program to print address of character using pointer 

/* C++ Program to print address of character */
#include<iostream>
using namespace std;
int main()
{
 char ch,*ptr;
 cout<<"Enter a character: ";
 cin>>ch;
 ptr=&ch;
 cout<<"Address of character "<<(void *)ptr;
 return 0;
}




Popular posts from this blog