home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C03 / SimpleStruct3.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  548 b   |  27 lines

  1. //: C03:SimpleStruct3.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Using pointers to structs
  7. typedef struct Structure3 {
  8.   char c;
  9.   int i;
  10.   float f;
  11.   double d;
  12. } Structure3;
  13.  
  14. int main() {
  15.   Structure3 s1, s2;
  16.   Structure3* sp = &s1;
  17.   sp->c = 'a';
  18.   sp->i = 1;
  19.   sp->f = 3.14;
  20.   sp->d = 0.00093;
  21.   sp = &s2; // Point to a different struct object
  22.   sp->c = 'a';
  23.   sp->i = 1;
  24.   sp->f = 3.14;
  25.   sp->d = 0.00093;
  26. } ///:~
  27.