title: Reading from a file and displaying it backwards
body: <p>I'm trying to write a program to read from a file and display the text backwards. - My loop backward loop is not working. Any suggestions?
  - Also if I'm reading a file that only contain floats integers or floats, how would I display them all as float?</p>
  
  <p>Thanks,</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  void seeReverseText(char fileName[])
  {
     ifstream fin(fileName);
     if (fin.fail())
     {
        cout &lt;&lt; "Error opening file " &lt;&lt; fileName &lt;&lt; endl;
        return;
     }
  
     cout.setf(ios::showpoint);
     cout.precision(2);
     cout.setf(ios::fixed);
  
     int i = 0;
     cout &lt;&lt; "New order:\n";
     while (!fin.eof())
     { 
       // this is what I was trying to do
       //  i++;
       // for (i--; i &gt;= 0; i--)
       //   fin &gt;&gt; fileName[i];
       //  cout &lt;&lt; "' " &lt;&lt; fileName[i] &lt;&lt; "'";
        fin &gt;&gt; fileName;
        cout &lt;&lt; fileName  &lt;&lt; endl;
     }
     fin.close();
  }
  
  
  int main()
  {
  
     char fileName[256];
     cout &lt;&lt; "Enter the filename: ";
     cin  &gt;&gt; fileName;
  
  
     seeReverseText(fileName);
  
     return 0;
  }
  </code></pre>