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 >
Wrap
Text File
|
1990-02-19
|
567b
|
35 lines
*****Listing 1*****
class File {
public:
File( char *name = "", char *mode = "r")
{
if( *name )
fp = fopen( name, mode);
else if( *mode == 'r' )
fp = stdin;
else
fp = stdout;
state = (int)fp;
}
~File() { if( fp) fclose( fp); }
Truth isok() { return state; }
Truth iseof() { return feof( fp); }
int get() { return getc( fp); }
void unget(int c) { (void)ungetc( c, fp); }
int peek() { int c = get(); unget(c); return c; }
void put( int c) { putc( c, fp); }
private:
FILE *fp;
int state;
};