Selasa, 3 Januari 2012

Coding for save the data into the wordpad or notepad by C++


#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;

int main()
{

char option;
cout << " \t\t\t **************************" <<endl;
cout << " \t\t\t  Welcome To Our Data Base " <<endl;
cout << " \t\t\t **************************" <<endl<<endl<<endl;
cout << "\n\np/s : Fill in the data base by using capital letter \n\n";
cout << "\n\nPlease Press Enter \n\n";

fstream outClientFile ;
outClientFile.open("apoi.dat",ios::out| ios::app);

if (!outClientFile)
{
cerr<<"File cannot open"<<endl;
return(1);
}

const int SIZE = 80;

char address[SIZE];
char fullName[SIZE];
char birthDay[SIZE];
double IcNumber;
char fullName1[SIZE];
char fatherName[SIZE];
char course[SIZE];
char faculty[SIZE];
char posscode[SIZE];
char status [SIZE];
char motherName[SIZE];

do {

cin.ignore();

outClientFile<< "\n\n\nData Base Profile\n\n"<<endl ;

cout <<endl <<"Full Name : ";
outClientFile<< "Name           : " ;
cin.getline (fullName,SIZE,'\n');
outClientFile<< fullName ;


cout<<endl<<"IC Number (Eg:890133-10-4531) : ";
outClientFile<< "\n\nIC Number      : ";

cin >> IcNumber;
cin.ignore();
outClientFile << IcNumber ;

cout<<endl<<"Birthday (Eg:15/11/1990) : ";
outClientFile<< "\n\nBirhtday       : ";
cin.getline (birthDay,SIZE,'\n');
outClientFile << birthDay ;

cout<<endl<<"Your Address : ";
outClientFile<< "\n\nAddress        : " ;
cin.getline (address,SIZE,'\n');
outClientFile << address ;

cout<<endl<<"Posscode: ";
outClientFile<< "\n\nPosscode       : " ;
cin.getline (posscode,SIZE,'\n');
outClientFile << posscode ;

cout<<endl<<"Faculty : ";
outClientFile<< "\n\nFaculty        : " ;
cin.getline (faculty,SIZE,'\n');
outClientFile << faculty ;

cout<<endl<<"Course : ";
outClientFile<< "\n\nCourse         : " ;
cin.getline (course,SIZE,'\n');
outClientFile << course ;


cout<<endl<<"Father Name : ";
outClientFile<< "\n\nFather Name    : " ;
cin.getline (fatherName,SIZE,'\n');
outClientFile << fatherName ;

cout<<endl<<"Mother Name : ";
outClientFile<< "\n\nMother Name    : " ;
cin.getline (motherName,SIZE,'\n');
outClientFile << motherName ;


cout<<endl<<"Status : ";
outClientFile<< "\n\nStatus         : " ;
cin.getline (status,SIZE,'\n');
outClientFile << status ;

outClientFile.close();

cout << "add contact: ";
cin>> option;
cout << endl;
system("CLS");

outClientFile.open("apoi.dat",ios::out| ios::app);
}while ((option =='y') || (option == 'Y'));
return 0;
}