RapidFax.com

I am trying to create a program that stores contacts and enables you to search through them.
I first needed to create a txt file and store the numbers and contacts as well as house number work number fax number adress etc….
we get to store as many as 200

Heres the code. This is a beginners course so detailed explanations I would greatttllly appreciate it guys!!

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{

struct contact
{ string lastName;
string firstName;
string homePhone;
string cellPhone;
string officePhone;
string pager;
string faxNumber;
};
string LastSearchName;

int choice;
int i=0;
ifstream inFile;
ofstream fout;
contact List[200];
string searchname;
int numbersearch;
cout<<"please enter the name you want for your file"<<endl;

inFile.open("filename.txt");

if (!inFile) {
cerr << "Unable to open file datafile.txt";
}

cout<<endl;

while(!inFile.eof())
{
inFile >> List[i].lastName;
inFile >> List[i].firstName;
inFile >> List[i].homePhone;
inFile >> List[i].cellPhone;
inFile >> List[i].officePhone;
inFile >> List[i].pager;
inFile >> List[i].faxNumber;

}
i=0;

cout<<"Press 0 to search by Name, Press any other number to search by Home number"<<endl;

cin>>choice;

if (choice==0)
{

cout<<"please enter the Last Name of the person you are trying to get contact of:"<<endl;
cin>>searchname;
cout<<endl;
i=0;
while (searchname!=LastSearchName)
{ LastSearchName=List[i++].lastName;

}

cout<<List[i].lastName<<" , "<<List[i].firstName<<endl;
cout<<"Home Phone: "<<List[i].homePhone<<endl;
cout<<"Office Phone: "<<List[i].officePhone<<endl;
cout<<"Pager: "<<List[i].pager<<endl;
cout<<"Fax Number: "<<List[i].faxNumber<<endl;
cout<<endl;
}

else
{cout<<"nevermind";}

inFile.close();

system ("PAUSE");
}

For some reason when I run the program I cannot get it to search through the names to get to the contact information for a specific person….ANY HELP GUYS? oh and can you guys help me in giving the user the ability to name the file its stored in??? im having problems with that… please very detailed results again I am a beginner

Tagged with:

Filed under: Fax Number Search