| vidhem (3) | |||
|
I m working on a small library management project (console) which has binary file i/o. When i save a structure to a file (.bin) and try 2 read it -> it works fine (till the console is closed). Once the console is re-opened, read is absurd and weird. Pls help to solve this..
P.S. I initialised iBook properly and saved using f1.write((char*)&b,sizeof(b))(b is an instance of iBook and f1 is a fstream) PLS help !! | |||
|
|
|||
| Felicia123 (176) | |||
|
edit your line 20 add 1 more | it should be
this is just smaller mistake. | |||
|
|
|||
| vidhem (3) | |
| dere comes only one |, i m sure .. n compiler too generates an error... | |
|
|
|
| KRAkatau (142) | |
It's a bitwise operation, not logical -> therefore one | is correct.On the topic: what do you mean by absurd and weird? How do you run your code? Which compiler/OS do you use? This line looks weird: tempStream.read((char*)tempBook,sizeof(tempBook));. If tempBook is a pointer - then the sizeof will return 4 and too few data will be read. If tempBook is an instance - then the conversion to char* should fail .
| |
|
|
|
| vidhem (3) | |
|
Ohh!! My bad... i declared tempBook as pointer... i m nw using tempStream.read((char*)&tempBook,sizeof(tempBook));with tempBook as a normal instance of iBook, it works just perfect... Thanks a ton... | |
|
|
|