It works now!
Above code (form my firs post) is incomplete.
Fstream in definition should have aditional token "ios::binary" in order to work as expected.
Thanks xwb for suggestion!
Thank you all for help!
Goran!
Hello!
Well, this is what I ment with " everything in file.bpd gets corrupted".
I gave above (my first post) the code that I was using to write numbers in binary file.
So everything works fine untill I get to number 10. After number 10 readings gets wrong.
Example 1. I wrote 10,20,30...
Well I tried the code under three compilers.
Borland C++ 5.5.1 for win32 gives offsets 0,3,5 and wrong reading of number 10 from file. The similar behaviour I noticed for Gnu gcc 3.2. under Cygwin wiht offsets 0,2,5
BUT gcc 2.95.4 (debian prerelease) is workin fine, normal, like you expect it...
Hello everyone!
Well, I have a starnge problem.
Here is the code, very simple:
#include <iostream.h>
#include <fstream.h>
typedef short int type;
int main () {
fstream file;
file.open("file.bpd", ios::in | ios::out);
type wr, rd;
cout << "writing..." << endl...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.