All pastes #390046 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-11 03:08 UTC
rendered paste body
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

#ifdef _WIN32
const int UNFORMAT = cout.flags();
#endif
#ifdef __GNUC__
const std::_Ios_Fmtflags UNFORMAT = cout.flags();
#endif

int main()
{
  double f; // degrees F
  double c; // degrees C

  ifstream fin;
  fin.open("temps.txt");
  if (!fin.good()) throw "I/O error";

  while (fin.good()) {
    fin >> c;
    fin.ignore(1000, 10);

    f = 9.0 / 5 * c + 32;
    cout << c << " degrees C is " << fixed << setprecision(1) << f << " degrees F\n";

    cout << setprecision(6); // default
    cout.flags(UNFORMAT); // turns off fixed
  } // while
  fin.close();

  return 0;
} // main