help making this code friendly

hello im having trouble finding making this code user friendly. wondering if someone can help me. sorry for my bad English. its my 2nd language

// This program writes data to a file
// using the put() function.
# include <fstream>
#include <iostream>
using namespace std;
int main()
{
char ch1 = 'U' ;
char ch2 = 'R' ;
short int age = 29;
ofstream outAges;
// Open the file. If it does not exist,
// it will be created.
// If the file exists, it will be overwritten.
outAges.open("A:\\Chapter2\\ages2.dat");
outAges.put(ch1);
outAges.put(' ');
outAges.put(ch2);
outAges.put(' ');
outAges << age;
outAges << "years old." << endl;
cout << ch1 << ' ' << ch2 << ' ' << age << " years old." << endl;
outAges.close( );
return 0;
}

The output sent to the screen is U R 29 years old.
The contents of ages.dat is U R 29 years old.
Last edited on
Topic archived. No new replies allowed.