Archived

This topic is now archived and is closed to further replies.

binary output probs..

This topic is 6389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites