# Include <cstdlib> # include <iostream> # include <fstream> # include <string> # include <iomanip> using namespace STD;/***/inline void eatline () {While (CIN. get ()! = '\ N') continue;} struct planet {char name [20]; double population; double G ;}; const char * file = "planets. dat "; int main (INT argc, char ** argv) {planet pl; cout <fixed <right; ifstream fin; Fin. open (file, ios_base: In | ios_base: Binary); If (Fin. is_open () {cout <"Here are the contents of" <file <"file: \ n"; while (Fin. read (char *) & pl, sizeof (PL) {cout <SETW (20) <Pl. name <":" <setprecision (0) <<SETW (12) <Pl. population <setprecision (2) <SETW (6) <Pl. G <Endl;} fin. close ();} ofstream fout (file, ios_base: Out | ios_base: app | ios_base: Binary); If (! Fout. is_open () {cerr <"can't open" <file <"file for output; \ n"; exit (exit_failure );} cout <"Enter planet name (enter a blank to quit): \ n"; cin. get (pl. name, 20); While (pl. name [0]! = '\ 0') {eatline (); cout <"Enter planetary population:"; CIN> Pl. population; cout <"Enter planet's acceleration of gravity:"; CIN> Pl. g; eatline (); fout. write (char *) & pl, sizeof PL); cout <"Enter planet name (enter a blank to quit): \ n"; cin. get (pl. name, 20);} fout. close (); Fin. clear (); Fin. open (file, ios_base: In | ios_base: Binary); If (Fin. is_open () {cout <"Here are the new contents of the" <file <"file: \ n"; while (Fin. read (char *) & pl, sizeof PL) {cout <SETW (20) <Pl. name <":" <setprecision (0) <SETW (12) <Pl. population <setprecision (2) <SETW (6) <Pl. G <Endl;} fin. close () ;}return 0 ;}