Question #44449

Declare a structure
telerec
in C++, containing name (20 characters) and telephone number. Write a
program to maintain a file of telephone records. The program should allow the following functions on
the
file:
1)
To append records in the file.
Display the telephone number(s) for a given name. If the name does not exist then display error mess
age
“record not found”.

Expert's answer

structure TN{
string name;
long telephoneNumber;

};
void display(string name){
for (int i = 0 ; i < r.size() ; i++){
if (r.name == name)cout<<r.number <<endl;
return;
}
cout<<"record not found\n";
}
main (){
vector <TN> telephoneRecords;
//here you can append any number of records

}
LATEST TUTORIALS
APPROVED BY CLIENTS