Download: srisc1.zip
binread.h#include <stdio.h>
#include <stdlib.h>
class binread {
public:
FILE *inp;
unsigned int data;
binread() { }
~binread() { close(); }
binread(wchar_t *filename) { open(filename); }
int open(wchar_t *filename);
void close() { if (inp) fclose(inp); inp = 0; }
bool hasNext();
unsigned int getInt() const { return data; }
};
inline bool binread::hasNext()
{
size_t count = fread(&data,4,1,inp);
return (count>0);
}
binread.cpp#include "stdafx.h"
#include "binread.h"
void pause();
int binread::open(wchar_t *filename)
{
errno_t nerr = _tfopen_s(&inp,filename,_T("r"));
if (nerr) {
wprintf(_T("file: %s not found\n"),filename);
pause();
exit(-1);
}
return 0;
}
Maintained by John Loomis, updated Thu Feb 15 23:50:03 2007