keep track of friends and number of days not spoken to, dynamic memory location Write a program that lets users keep track of the last time they talked to each of their friends. Users should be able to add new friends (as many as they want!) and store the number of days ago that they last talked to each friend. Let users update this value (but don't let them put in bogus numbers like negative values). Make it possible to display the list sorted by the names of the friends of by how recently it was since they talked to each friend.

This is the code I have written so far. I'm having problems with the array size not growing as it should do. Also I'm unsure about how to go about list the names with numbers of days out.

#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int *growArray (int * friends, int * size)
{
    *size *= 2;
    int *new_friends = new int[*size];
    for (int i=0; i &lt; *size; i++) {
        new_friends[i] = friends[i];
    }
    delete [] friends;
    return new_friends;
}

string *growArray2 (string * name1, int * size)
{
    *size *= 2;
    string *new_name2 = new string[*size];
    for (int i=0; i &lt; *size; i++) {
        new_name2[i] = name1[i];
    }
    delete [] name1;
    return new_name2;
}

void printArray (string *name1, int *friends,int size, int element_set)
{
    cout &lt;&lt; "the total size of the array is: " &lt;&lt; size &lt;&lt; endl;
    cout &lt;&lt; "Values in the array: " &lt;&lt; endl;
    for (int i = 0; i &lt; element_set; ++i)
    {
        cout &lt;&lt; name1[i] &lt;&lt; "[" &lt;&lt; i &lt;&lt; "] = " &lt;&lt; friends[i] &lt;&lt; " days since you last spoke to them" &lt;&lt; endl;
    }
}

int main()
{
    string exit = "X";
    string name;
    int noDays;
    int next_element = 0;
    int size = 4;
    int *friends = new int[size];
    string *name1 = new string [size];
        cout &lt;&lt; "Please enter your friends name" &lt;&lt; endl;
        cin &gt;&gt; name;
        cout &lt;&lt; "Please enter no of days you last spoke to them" &lt;&lt; endl;
        cin &gt;&gt; noDays;
    while(true) {
        if (size == next_element+1) {
            friends = growArray(friends, &amp;size);
            name1 = growArray2(name1, &amp;size);
        }
        friends[next_element] = noDays;
        name1[next_element] = name;
        next_element++;
        printArray(name1, friends, size , next_element);
        cout &lt;&lt; "Please enter your friends name or X to exit" &lt;&lt; endl;
        cin &gt;&gt; name;
        if (name == exit) {
            break;
        }
        cout &lt;&lt; "Please enter no of days you last spoke to them" &lt;&lt; endl;
        cin &gt;&gt; noDays;

        }
        delete name1;
        return 0;
}
First of all the "growArray" function will never be called since you put it inside an if block that runs only once. when the if statement is evaluated your size is 10 and your next_element+1 is 1 and you never check for (size == next_element+1) again.