title: How to reverse data using an array of pointers (parse binary file)
body: <p>I am parsing a binary file using a specification. The file comes in big-endian mode because it has streamed packets accumulated. I have to reverse the length of the packets in order to "reinterpret_cast" them into the right variable type. (I am not able to use net/inet.h function because the packets has different lengths).</p>
  
  <p>The read() method of the ifstream class puts the bytes inside an array of chart pointers. I tried to do the reversion by hand using a but I cannot figure out how to pass the "list of pointers" in order to change their position in the array.</p>
  
  <p>If someone knows a more efficent way to do so, please let me know (8gb of data needs to be parse). </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  void reverse(char &amp;array[]);
  
  using namespace std;
  
  int main ()
  {
      char *a[5];
      *a[0]='a'; *a[1]='b'; *a[2]='c'; *a[3]='d'; *a[4]='e';
  
      reverse(a);
  
      int i=0;
      while(i&lt;=4)
      {
          cout &lt;&lt; *a[i] &lt;&lt; endl;
          i++;
      }
      return 0;
  }
  void reverse(char &amp;array[])
  {
      int size = sizeof(array[])+1;
      //int size = 5;
      cout &lt;&lt; "ARRAY SIZE: " &lt;&lt; size &lt;&lt; endl;
  
      char aux;
      for (int i=0;i&lt;size/2;i++)
      {
              aux=array[i];
              array[i]=array[size-i-1];
              array[size-i-1]=aux;
      }
  }
  </code></pre>
  
  <p>Thanks all of you for your help!</p>