calculation from text file

Hello, I'm trying to create a looped program that collects celsius temperatures from a text file and does the calculation for all the numbers to be transformed into fahrenheit, but I keep on receiving compiler errors. This is my code so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <fstream> 
#include <iostream> 
#include <string> 
#include <iomanip>
using namespace std; 
  
int main() 
{ 
  ifstream fin; 
  fin.open("temps.txt"); 
  if (!fin.good()) throw "I/O error"; 

  double f; // degrees F 
  double c; // degrees C 
  cout << fixed << setprecision(1); 
  
  while (true) 
  { 
    if (!fin.good()) break; 
 
    getline(fin, c); 

    cout << "The temperature in degrees Celsius is " << c;  
  
    f = 9.0 / 5 * c + 32; 

    cout << "The temperature in degrees F is " << f << endl; 



  } // while 
  fin.close(); 
  
  return 0; 
} // main 



Any advice will be appreciated! Thanks!
Unfortunately, getline() doesn't let you put that value into a double, like you're trying to do with c. If you were to instead do the following:
 
fin >> c;

It'd all check out.
Topic archived. No new replies allowed.