dynamic array to two functions
<p>I created a program that will use a dynamic array by using pointer to find the max and min from a set for integer that the user will enter.</p>

<p>I actually can get the output of max, but not for min; I found out my dynamic array will result to 0 after the calculation from the function of max, and made my min became the value of the assigned value of min.</p>

<p>I have no idea why it is like this - I tried many ways, but these were useless so can someone explain why, and provide a solution if possible or give me some hint for how to get through the solution?</p>

<hr>

<p>Thank your replies</p>

<p>seem like my code had confused to your</p>

<p>Sorry</p>

<p>the program intent to get the maximum and minimum digits from an amount of integers</p>

<p>From I what I tried to say is after calculation from the function of max, the data from the dynamic array would become 0, and when program go through the function of min, it would not gonna run because the data from dynamic array had been set to 0</p>

<p>So actually what I wanna ask is is there anyway to make the data from the dynamic array not become to 0 after the function of max?</p>

<p>Sorry for my poor English</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

void max(int*, int);
void min(int*, int);

int main()
{
   int *ptr;
   int i;
   int size;

   cout &lt;&lt; "how many integer: ";
   cin &gt;&gt; size;

   ptr = new int[size];

   for (i = 0; i &lt; size; i++)
   {
      cout &lt;&lt; "integer#" &lt;&lt; i &lt;&lt; ": ";
      cin &gt;&gt; *ptr + i;
   }

   max(ptr, size);
   min(ptr, size);

   delete [] ptr;

   return;
}

void max(int* ptr, int size)
{
   int i;
   int j;
   int max = 0;

   for (i = 0; i &lt; size; i++)
   {
      while (*ptr + i != 0)
      {
         j = *ptr + i % 10;

         if (j &gt; max)
         {
            max = j;
         }

         *ptr + i /= 10;
      }
   }

   cout &lt;&lt; max &lt;&lt; endl;
}

void min(int* ptr, int size)
{
   int i;
   int j;
   int min= 0;

   for (i = 0; i &lt; size; i++)
   {
      while (*ptr + i != 0)
      {
         j = *ptr + i % 10;

         if (j &lt; min)
         {
            min= j;
         }

         *ptr + i /= 10;
      }
   }

   cout &lt;&lt; min&lt;&lt; endl;
}
</code></pre>
