Modern versions of windows require admin privilages to write directly to C:\.
Try putting the file in a different folder (desktop? or maybe just use "x.bin" and put it in the current directory).
@Disch: I thought of that. But if that's the case, why would it open the file in the first place? it would've complained about not opening the file. the function fstream::is_open() returns true!!! I changed the directory to desktop and I'm still getting the same result.
@EssGeEich: I want to store them as doubles, not as chars.
There's something I can't see in here... any ideas?
If you want to read that file on notepad, notepad reads in every file as CHARs. If you want to store them as doubles and want to retrieve them back as doubles, you can do it. but if you want to open your newly created file with a text editor, save it as text.
P.S. : Use Notepad++ instead of notepad, it shows you some symbols in place of unrepresentable chars ([NULL],[EDX]... and similars.)
I'm creating a tempatised class for mathematics that has the option of writing and reading files. I'm not just playing around with fstream... I'm writing that file and trying to read it with my container.
This is really weird... I give up...!
If you got any ideas or similar experience, guys, please let me know.
I know exactly what you made wrong in the previous program! char* buffer = (char*)&temp.front();
temp.front() is an iterator, which means it's kinda a pointer, so basicly you are converting double** to char*, which compiles but gives the wrong answer. try char* buffer = (char*)temp.front();(without the ampersand)
front() returns a reference to the first element in the vector.
begin() returns an iterator to the first element in the vector.
There should be no difference between using std::fstream and using the devil's struct, besides the latter being slightly more evil.