Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Node.h"
- #include <fstream>
- void write_binary()
- {
- std::ofstream bin("tst.bi", std::ios::out|std::ios::binary);
- double v = 7;
- bin << v;
- bin.close();
- }
- void read_binary()
- {
- std::ifstream bin("tst.bi", std::ios::in|std::ios::binary);
- double v;
- bin >> v;
- std::cout << v << std::endl;
- }
- std::ofstream& operator << (std::ofstream& out, const double& v)
- {
- out << v;
- return out;
- }
- std::ifstream& operator >> (std::ifstream& in, double& v)
- {
- in >> v;
- return in;
- }
- int main()
- {
- //test_node();
- write_binary();
- read_binary();
- std::ofstream ofile("test.bi", std::ios::out|std::ios::binary);
- double v = 7;
- ofile << v;
- std::ifstream ifile("test.bi", std::ios::in|std::ios::binary);
- double iv;
- ifile >> iv;
- std::cout << iv << std::endl;
- std::cout << "Hello world!" << std::endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment