Practice problems Jumping into c++

Q3. Create an address book program that builds on problem #1—this time, the user should be able to not just fill out a single structure, but should be able to add new entries, each with a separate name and phone number. Let the user add as many entries as he or she wants—is this easy to do? It is even possible? Add the ability to display all, or some of the entries, letting the user browse the list of entries.

at pg no. 129

please anyone help me with this question
Last edited on
It's very easy to do.

Make a vector of whatever struct you're using. Each time the user enters a new one, push it onto the back of the vector.
i have not reached that level yet i am following jumping into c++ book and till now i haven't learned vectors
Learn vectors. If the book is a C++ book yet it wants you to use arrays before vectors, throw it away.
Last edited on
Q3. Create an address book program that builds on problem #1

What was problem #1?

You need a kind of struct and an array of these structs, like so.

1
2
3
4
5
6
7
8
9
10
11
12
struct Contact
{
   string name;
   string phone;
};

const int MAX_ELEMS = 100; // choose any number you need

int NumElems; // number of Contacts in the array

Contact PhoneBook[MAX_ELEMS];






what is const used for
To make it difficult to change a value after you've initialised it.
Topic archived. No new replies allowed.