home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_01 / 8n01111a < prev    next >
Text File  |  1990-02-19  |  567b  |  35 lines

  1. *****Listing 1*****
  2.  
  3.  
  4. class File {
  5. public:
  6.     File( char *name = "", char *mode = "r")
  7.     {
  8.         if( *name )
  9.             fp = fopen( name, mode);
  10.         else if( *mode == 'r' )
  11.             fp = stdin;
  12.         else
  13.             fp = stdout;
  14.         state = (int)fp;
  15.     }
  16.  
  17.     ~File()            { if( fp) fclose( fp); }
  18.  
  19.     Truth isok()        { return state; }
  20.  
  21.     Truth iseof()        { return feof( fp); }
  22.  
  23.     int get()        { return getc( fp); }
  24.  
  25.     void unget(int c)    { (void)ungetc( c, fp); }
  26.  
  27.     int peek()        { int c = get(); unget(c); return c; }
  28.  
  29.     void put( int c)    { putc( c, fp); }
  30. private:
  31.     FILE *fp;
  32.     int state;
  33. };
  34.  
  35.