I'm in an intro C++ class and am suppose to make a phonebook program that will show a list of commands then read in a name,number ,and notes into a file. Then be able to retrieve a name, or display the whole contact list. I'm having trouble getting the find option and list option to work, any help would be great. This is the code I have so far.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct contact{
string name, number, notes;
};
ofstream output("c:\\phonedata\\contactlist.txt");
int rec_num = 0;
int num_entries = 0;
string toupper (string S){
for(size_t i=0; i < S.length(); i++)
S[i] = toupper(S[i]);
return S;
}
void choice(){
cout << "The avaliable options are\n";
cout << "Enter e to enter a new name. \n";
cout << "Enter f to find a name. \n";
cout << "Enter l to see your contact list. \n";
cout << "Enter q to quit the program \n";
cout << "\n";
}
class Entry{
public:
string name, number, notes;
contact contactlist[100];
};
void listAllcontacts(){
cout << "Name: " << contactlist.name;
}
string notes[40];
int main(){
char command;
char notes[40];
string name, number;
string Filename;
choice();
cout << "Command: ";
cin >> command;
while (command != 'q'){
switch(command){
case 'e': cin >> name; cout <<"enter number\n";
cin >> number; cout <<"enter notes\n";
cin.getline(notes,40); break;
case 'f': cin >> name; find ;name(name); break;
case 'l': listAllcontacts(); break;
}
}
if (command == 'q')
cout << "Good bye";
return 0;
}