Sunday, January 24, 2016

Writing in a text file using C++

Here is a sample program that I wrote a long time ago to write the content in a text file using C++. The code is very simple and easy to understand.  

If you have some questions please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <fstream>

using namespace std;

main() {
     string name,course, school, position;
     int age=0;

     cout << " ======= Resume Maker Version 1.0 =============";
     cout << "\n\n";

     cout << "Enter the name of the Person : ";
     getline(cin,name);
     cout << "Enter the age of the Person : ";

     cin >> age;

     cout << "Enter the course of the Person : ";
    cin.ignore(80,'\n');
    getline(cin,course);

     cout << "Enter the school Graduated  : ";
     getline(cin,school);
     cout << "Enter the Position Applying : ";
     getline(cin,position);

     cout << "\n\n";
     cout << "\t  RECORDS HAS BEEN SAVED IN THE DATABASE";

    ofstream my_file("resume.txt");
    my_file << "\n\n\t\t ==== RESUME VITAE ==== ";
    my_file << "\n\n";
    my_file << "\n \t Name      :  " <<name;
    my_file << "\n \t Age       :  " <<age;
    my_file << "\n \t Course    :  " <<course;
    my_file << "\n \t School    :  " <<school;
    my_file << "\n \t Position  :  " <<position;

    my_file.close();
    return 0;
}






No comments:

Post a Comment