Im a beginner at C++ . And this is the project im asked to do. i wanna know how to store phone records and retrieve it even after the program is closed.
do
{
getch();
clrscr();
cout<<" *----------------------------------* \n";
cout<<" |1 | GO TO MAIN MENU | \n";
cout<<" |==|===============================| \n";
cout<<" |2 | EXIT | \n";
cout<<" *----------------------------------* \n";
cout<<"ENTER YOUR OPTION ";
cin>>m;
}
while(m!=1&&m!=2);
if(m==1)
continue;
else if(m==2)
exit(0);
break;}
case 2:do
{clrscr();
cout<<" \n";
cout<<" THIS PROGRAM IS CALLED TELEPHONE DIRECTORY \n ";
cout<<" PLEASE DO AS DIRECTED:- \n ";
cout<<" USE NUMPAD TO SELECT THE OPTIONS\n \n";
cout<<"\n\n\n\n";
cout<<" *----------------------------------* \n";
cout<<" |1 | TO GO TO MAIN MENU | \n";
cout<<" |==|===============================| \n";
cin>>m;
if(m==1)
break;
if(m==2)
cout<<"PLEASE DO AS DIRECTED\n";
}while(m!=1&&m!=2);break;
case 3:
do
{clrscr();
cout<<" \aTHE\a PROJECT\a IS SUBMITTED\a BY\n\tROHIT\a\n &&GOPIKRISHNAN\n\a\n\n WE CONVEY OUR SINCERE THANKS TO SUJA TEACHER\n\a FOR GIVING US THE\a\n\n \nOPPORTUNITY\n\a\tWE ALSO LIKE TO THANK ALL OTHER PEOPLE\n\n\a WHO SUPPORTED US\n\n\n\n\n\t\a..\aTHANK\n\t\a YOU\a...\a " ;
cout<<"\n\n";
cout<<" *----------------------------------* \n";
cout<<" |1 | TO GO TO MAIN MENU | \n";
cout<<" |==|===============================| \n";
cout<<" |2 | EXIT | \n";
cout<<" *----------------------------------* \n";
cin>>m;}
while(m!=1 && m!=2);
if(m==1)
continue;
if(m==2)
exit(0);
break;
case 4:exit(0);break;
default:
clrscr();
continue;
}}}
#include<fstream> //You don't need .h for C++ libraries, .h is for C ones
ifstream inFile; // used to read from files
ofstream outFile; / used to write to files
string data;
outFile.open("DataFile"); // open file to write data to
outFile << data; // write actually data
outFile.close();
inFile.open("DataFile"); // open prev written data file
if (inFile) // if file opened correctly
inFile >> data; // read data back into the string variable