home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
gnu
/
g__lib
/
test0.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-23
|
1KB
|
78 lines
#include <std.h>
#include <stdio.h>
#include <stddef.h>
// change the following if ld++ and crt1+.o are in non-standard directories
#ifndef LDXX
#define LDXX "/usr/local/lib/gcc-ld++"
#endif
#ifndef CRT1X
#define CRT1X "/usr/local/lib/gcc-crt1+.o"
#endif
class ifile
{
FILE *fp;
char *name;
public:
ifile (char *name)
{
this->name = new char[strlen(name) + 1];
strcpy (this->name, name);
if ((fp = fopen (name, "r")) == NULL)
{
fprintf (stderr, "could not open input file `%s'\n", name);
exit (1);
}
}
~ifile ()
{
fclose (fp);
if (fp) fprintf (stderr, "closing input file `%s'\n", name);
}
ifile& operator>> (int &i)
{ fscanf (fp, "%d", &i); return *this; }
ifile& operator>> (char *p)
{ fscanf (fp, "%s", p); return *this; }
};
class ofile
{
FILE *fp;
char *name;
public:
ofile (char *name)
{
this->name = new char[strlen(name) + 1];
strcpy (this->name, name);
if ((fp = fopen (name, "w")) == NULL)
{
fprintf (stderr, "could not open output file `%s'\n", name);
exit (1);
}
}
~ofile ()
{
fclose (fp);
if (fp) fprintf (stderr, "closing output file `%s'\n", name);
}
ofile& operator<< (int i)
{
fprintf (fp, "%d", i);
fflush (fp);
return *this;
}
ofile& operator<< (char *p)
{
fprintf (fp, "%s", p);
fflush (fp);
return *this;
}
};