Here is my attempt
using namespace std;
int main()
{
mt19937 mt(time(0));
cout << mt() << endl;
cout << "----" << endl;
std::ofstream ofs;
ofs.open("/path/save", ios_base::app | ifstream::binary);
ofs << mt;
cout << mt() << endl;
cout << "----" << endl;
std::ifstream ifs;
ifs.open("/path/save", ios::in | ifstream::binary);
ifs >> mt;
cout << mt() << endl;
return 0;
}
Here is a possible output
1442642936
----
1503923883
----
3268552048
I expected the two last number to be the same. Obviously, I have failed to write and/or read my mt19937. Can you help fixing this code?
Aucun commentaire:
Enregistrer un commentaire