binary output probs..
I can get this code to write correctly to a file, but it will read as 0/0/0.
What can i do to stop it ? Ive tried some casting but its gives me a cast error error message about operator not defined.
help !
~V''lion
template
data_t file::fget(long offset)
{
data_t value;
nfile.seekg(offset, ios::beg);//resets the file pointer to 0
nfile.read((char *) &value, sizeof(data_t) );
return value;
}
struct DATE
{
short day;
char fil1;
short month;
char fil2;
short year;
DATE(short fday=0, short fmonth=0, short fyear=0)
{
fil1=fil2 = ''/'';
day=fday;
month=fmonth;
year=fyear;
}
};
int main()
{
file fio = "test.bin";
DATE ret;
DATE valu(1000,2000,3000);
fio.write(valu);
ret = fio.fget(0);
cout << ret.day << '' '' << ret.fil1 << '' '' << ret.month << '' '' << ret.fil2 << '' '' << ret.year;
return 0;
}
I came, I saw, I got programmers block.
~V''lion
~V'lionBugle4d
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement