Hello! I'm trying to learn how to use binary files instead of text files (supposedly they will take up less space?) and I have the following small test program:
Ha, I always thought it was 16. sizeof(double) is safer I guess but in the end I will use this in a code where speed is crucial, and that would be a tiny bit slower right? (for a lot and lot of repetitions)
Somehow passing the ofstream to a function I get the error " Request for member 'write' in 'bout', which is of non-class type 'std::ofstream*' ." I don't understand why ofstream now can't be used like this.
*bout.write((constchar *) &d, sizeof(double));
is evaluated as *(bout.write((constchar *) &d, sizeof(double)));
so you have to put parentheses around *bout to make it work. (*bout).write((constchar *) &d, sizeof(double));
or you can use the arrow syntax (usually more convenient) bout->write((constchar *) &d, sizeof(double));