anyone have some quick advice with header files in C++ guys

hey guys, my code works and all, but my professor just told me that I need to include a .h file.
this program allows people to store numbers and contacts in a file and read it through the program in order to search through the contacts,

everything works, just wanted help he said he wanted me TO

design the user interface to get the desired information.

Is that what I already did? I think he wants a .h file help please


#include <iostream>
#include <fstream>
#include <string>


using namespace std;
int main()
{
int a1;
int a2;
int a3;
int a4;

int n;


int choice;
string filename;


struct contact //THE INFAMOUS STRUCT.
{ string lastName;
string firstName;
string homePhone;
string cellPhone;
string officePhone;
string pager;
string faxNumber;
};


ifstream inFile;
int i; .
contact List[200];
string searchname;
string searchnum; NUMBER.


cout<<"Please enter the name of your file below (including .txt, .RTF....etc)"<<endl;

cout<<endl;

cin>>filename;
inFile.open(filename.c_str());
if (!inFile) OF
{cout<<"your file did not open"<<endl<<endl;}
if (inFile)
{
cout<<endl<<"How many contacts do you have in your file?"<<endl<<endl; //used for counter of loop storing struct arrays.
cin>>n;



cout<<endl<<"how would you like to search for your contacts?"<<endl<<"if by name press 0,"<<endl<<"or press any other number to search by Home Phone number:"<<endl<<endl;

cin>>choice;

if (choice==0)
{

i=0;
while(i<n) //
{ //
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=i+1; //
//
//
}
i=0;
cout<<endl<<"enter The last name of the contact you are trying to reach"<<endl<<endl;

cin>>searchname;
i=0;
while (searchname!=List[i].lastName)
{i++;}




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




else
{

i=0;
while(i<n)
{
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=i+1;


}
i=0;
cout<<"enter the Home Phone number of the contact you want:"<<endl<<endl;

cin>>searchnum;
i=0;
while (searchnum!=List[i].homePhone)
{i++;}




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







inFile.close();
system ("pause");
}
closed account (S6k9GNh0)
Design the user interface to get the desired information.
Rofl();

Next time use the Code BBCODE please.
Topic archived. No new replies allowed.