Advanced I/O File operations, with functions
<p>please excuse my newbie format.  I am trying to get a pass by ref function to read from an existing file from first position to last position.  I was atttempting to have it read and display the files contents by first using seekg to read how many characters or bytes are in the file.  I have been using bits and pieces from my professors examples and the textbook.  I have a feeling it is more of an issue with my function then the organization.  It compiles and it appears to count right but not displaying the contents of the arrays.txt file.  Any help would be appreciated as always. </p>

<pre><code>  Using Bloodshed...

#include &lt;iostream.h&gt;
#include &lt;fstream.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;iomanip&gt;

using namespace std;
char  x;
void calcFunc(fstream &amp;, char &amp;, long&amp;, long&amp;);
 int main()
 {

 fstream file;
 char ch, choice;
 long offset, last, first;

file.open("arrays.txt");
if(file.fail())
            {
            cout &lt;&lt;" file name cannot be found \n";
            system("pause");
            exit(1);
            }

cout &lt;&lt; "Hello You!  Please choose Option A,B,C, or D:   "  &lt;&lt;endl&lt;&lt;endl;;

cout &lt;&lt;  "A.  READ THE FILE FROM FIRST POSITION TO LAST. "  &lt;&lt;endl;
cout &lt;&lt;  "B.  READ THE FILE FROM THE LAST TO THE FIRST IN REVERSE."  &lt;&lt;endl;
cout &lt;&lt;  "C.  READ THE FILE FROM FIRST POSITION TO  ANY PLACE."  &lt;&lt;endl;
cout &lt;&lt;  "D.  READ FILE FROM ANY PLACE TO ANY PLACE. "  &lt;&lt;endl &lt;&lt;endl;
cout &lt;&lt; "A, B, C, OR D,: ";
cin &gt;&gt; choice;

cout &lt;&lt;endl&lt;&lt;endl;

switch(choice)
{

 case 'A':  file.seekg(0L, ios::end);
          last = file.tellg();
          cout &lt;&lt; last;
          system("pause");
          calcFunc(file,  ch, offset, last);
          cout &lt;&lt; offset&lt;&lt;"  " &lt;&lt;last &lt;&lt;"  " &lt;&lt;x &lt;&lt;"  " &lt;&lt;ch;
          system("pause");

          break;

   default:  cout &lt;&lt; "please enter appropriate value";
         } 



           return (0);
           }

  void  calcFunc(fstream &amp;file,  char &amp;x,long &amp; offset,  long &amp; last)
         {
                       for( offset =  last; offset &gt; 0; offset --)

                        {
                         x = file.get();
                         cout &lt;&lt; x;
                         return x;


                         }
          }
</code></pre>
