Code.GeekInterview.com
 
Code Samples C++
 

Void Pointers


Code ResourceAuthor: shanthankumar  

Difficulty Level: Beginner

Published: 6th Jan 2010   Read: 2289 times  

Filed in: C++
Add Comment


 

 

Sponsored Links


 

 

 


Sample Code
  1. #include<constream.h>
  2. int i;
  3. float f;
  4. char c;
  5. void main()
  6. {
  7.         void *p;        //declaring void pointer
  8.         p=&i;           //initializing with int variable address
  9.         *(int *)p=10;
  10.         cout<<endl<<i;
  11.         p=&f;            //initializing with float  variable address
  12.         *(float *)p=10.55;
  13.         cout<<endl<<f;
  14.          p=&c;            //initializing with char variable address
  15.         *(char *)p='s';
  16.         cout<<endl<<c;
  17.         getch();
  18. }
  19.  
Copyright GeekInterview.com


Next Article: Using gotoxy()


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. Priya36670
2. chowsys14957
3. bipin_vaylu13579
4. raghu.mohindru8719
5. Subashini7235
6. vimal.fire6980
7. rachittyagi6628
8. venki_madesh6208
9. prabha6193
10. vipin gupta5907

Active Coders

Refined Tags