home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 7.ddi / MWHC.007 / B < prev    next >
Encoding:
Text File  |  1992-04-01  |  1.2 KB  |  53 lines

  1. /*
  2.  * Example 8: FileManager.  Retrives the linked list of ints saved by Example 7.
  3.  * This example appears in Section 11.2 of the manual.
  4.  *
  5.  * $Header:   E:/vcs/toolexam/example8.cpv   1.1   01 Apr 1992 16:51:12   keffer  $
  6.  *
  7.  ****************************************************************************
  8.  *
  9.  * Rogue Wave Software, Inc.
  10.  * P.O. Box 2328
  11.  * Corvallis, OR 97339
  12.  * Voice: (503) 754-2311    FAX: (503) 757-7350
  13.  *
  14.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  15.  * protection under the laws of the United States and other countries.
  16.  *
  17.  ***************************************************************************
  18.  *
  19.  * $Log:   E:/vcs/toolexam/example8.cpv  $
  20.  * 
  21.  *    Rev 1.1   01 Apr 1992 16:51:12   keffer
  22.  * Now includes <rw/xxx.h>
  23.  * 
  24.  */
  25.  
  26. #include <rw/filemgr.h>
  27. #include <rw/rstream.h>
  28.  
  29. struct DiskNode {
  30.   int      data;
  31.   RWoffset nextNode;
  32. };
  33.  
  34. main()
  35. {
  36.   RWFileManager fm("linklist.dat");
  37.   
  38.   fm.SeekTo(fm.start());
  39.   RWoffset next;
  40.   fm.Read(next);
  41.   
  42.   DiskNode n;
  43.   while (next != NIL) {
  44.     fm.SeekTo(next);
  45.     fm.Read(n.data);
  46.     fm.Read(n.nextNode);
  47.     cout << n.data << "\n";
  48.     next = n.nextNode;
  49.   }
  50.   return 0;
  51. }
  52.  
  53.