title: Accessing Dynamic Arrays Through Pointers
body: <p>Sorry if this is a stupid question, but I'm a novice programmer learning C++.</p>
  
  <p>I have an assignment in which an input txt file is provided with 16 lines of 1-5 digit numbers with 5 numbers max in each row. We are supposed to write a function findmax to use in main to output the max number in each row into another txt file.</p>
  
  <p>My code has no current compiling errors I'm more just stuck on how to actually utilize this function in main and pass it into the outuput file. Sorry again if this is really simple.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include&lt;fstream&gt;
  using namespace std;
  
  int *make( int n)
  {
  #if 0
      int *a = new int[n];
  #else
      int a[n];
  #endif
      for( int i=0; i &lt; n; ++i) a[i] = i;
  
      return a;
   }
  
  int findmax(int x1,int x2,int x3,int x4, int x5)
  {
      for(int i=0;i&lt;5;i++)
      {
          int n, temp;
          int a[i];
          if(a[i]&gt;temp)
              temp=a[i];
          return temp;
      }
  
  }
  int main() 
  {
      int n;
      int x1, x2, x3, x4, x5, y1, y2, y3, y4, y5;
      cout &lt;&lt; "Enter number of lines n in the input file." &lt;&lt; endl;
      cin &gt;&gt; n;
      int *a = make(n);
  
      for( int i = 0; i &lt; n; ++i) cout &lt;&lt; a[i] &lt;&lt; " "; cout &lt;&lt; endl;
  
      ifstream infile; infile.open("/home/labs/lab4/lab4_input.txt");
      ofstream outfile; outfile.open("/home/labs/lab4/lab4_output.txt");
      if( !infile.is_open()) cout &lt;&lt; "open infile failed\n";
  
      infile &gt;&gt; x1 &gt;&gt; x2 &gt;&gt; x3 &gt;&gt; x4 &gt;&gt; x5;
      findmax( x1, x2, x3, x4, x5);
      outfile &lt;&lt; y1 &lt;&lt; " " &lt;&lt; y2 &lt;&lt; " " &lt;&lt; y3 &lt;&lt; " " &lt;&lt; y4 &lt;&lt; " " &lt;&lt; y5 &lt;&lt; endl;
      infile.close();
      outfile.close();
      return 0;
  }
  </code></pre>