Advertisement
Jambix64

Pointer_Void

Aug 12th, 2016
1,248
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <string.h> //Fica o strcpy;
  4.  
  5. using namespace std;
  6. // student name Naelson c/c++ advanced !
  7. // Date 2016/12/08
  8. int main(){
  9.  
  10.     //void* pointer  for any type of variable!
  11.     //Exemple
  12.  
  13.     int x=10;
  14.     float y=1.2;
  15.     double w=254.657; // Variable pre defined
  16.     char x1 [] = "Jambax64";
  17.     void* ptrAll;
  18.  
  19.     ptrAll = & x,y,w;
  20.  
  21.     // Use a casting with asterisk. following of pointer declared in start of line.
  22.      cout<<*(int *)ptrAll<<endl;
  23.  
  24.    return 0;
  25. }
Advertisement
RAW Paste Data Copied
Advertisement