i have a problem with my program it can only search 1 account number at a time...
and after i search again... it will not display the search number... hope someone can help my with the missing parts of these program.. tnx in advance...
goal:
to search id number more than once... without starting the program all over again.. tnx
here i my program.. included the textfile here... tnx
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int ShowMenu();
int main()
{
string sFilePath("MyRecord.txt");
string dLine(""), input("");
ifstream inFile(sFilePath.c_str());
int choice = 1;
system("cls");
system("Color 4E");
while ( choice != 3 )
{
do {
if (choice > 3 || choice <= 0)
{
cout << "\nAi da da! we don't have that option. Please select again. \n";
cout << "\nPress <Enter> key to continue ... ";
fflush(stdin);
cin.get();
}
choice = ShowMenu();
} while ( choice < 0 || choice > 3 );
if ( choice != 3 )
switch (choice)
{
case 1:
cout<<""<<endl;
cout<<"I=====Account Verification====I"<<endl;
cout<<""<<endl;
cout<<" Enter Account Number:";
cin >> input;
cout<<""<<endl;
cout<<"I=============================I"<<endl;
cout<<" -=PROCESS COMPLETED=- "<<endl;
cout<<"I=============================I"<<endl;
cout<<""<<endl;
input += ",";
{
getline(inFile, dLine);
if(dLine.find(input) != dLine.npos)
{
cout<<"I=====Account Information=====I";
cout<<""<<endl;
cout<< dLine <<"\n\n";
cout<<"I=============================I"<<endl;
}
}
fflush(stdin);
cin.get();
break;
case 2:
string line;
ifstream akunfile("myRecord.txt");
cout<<"I======Account Records======I"<<endl;
if(akunfile.is_open())
{
while(!akunfile.eof())
{
getline(akunfile,line);
cout<<""<<endl;
cout<<"[] "<<line<<endl;
}
akunfile.close();
cout << "\nPress <Enter> key to continue ... "<<endl;
}
else
cout<<"Indi ma open akun file";
fflush(stdin);
cin.get();
break;
}
}
fflush(stdin);
cin.get();
return 0;
}
int ShowMenu()
{
int choice;
system("cls");
cout<<"I================================I"<<endl;
cout<<"I = = = ===================== I"<<endl;
cout<<"I = = = = =================== I"<<endl;
cout<<"I = = = = = ================= I"<<endl;
cout<<"I = = = = = = = = = I"<<endl;
cout<<"I = = = = = ======= = = = I"<<endl;
cout<<"I = = = = ======= = = = = I"<<endl;
cout<<"I = = = ======= = = = = = I"<<endl;
cout<<"I = = = = = = = = = I"<<endl;
cout<<"I = = = ======= = = = = = I"<<endl;
cout<<"I = ============= = = = = I"<<endl;
cout<<"I ================= = = = I"<<endl;
cout<<"I---------LASALTECH INC.---------I"<<endl;
cout<<"I Programmed by: I"<<endl;
cout<<"I Kirvie M. Palencia I"<<endl;
cout<<"I===========[2010-2011]==========I"<<endl;
cout<<""<<endl;
cout<<" [1]Search Account Number.\n";
cout<<" [2]Show All Records.\n";
cout<<" [3]Terminate program. \n";
cout<<""<<endl;
cout<<"Enter your choice: ";
while(!(cin >>choice) )
{
cout << "\nAre you drunk? that's invalid option."
<< "\nRe-Enter your choice: ";
cin.clear();
fflush(stdin);
}
return choice;
}
hope someone can figure out whats missing in my program...