converting celsius to fahrenheit

I'm trying to read a number from a text file that is the degrees in Celsius, and then I'm supposed to calculate that number into the equivalent temperature in Fahrenheit, and the program is supposed to output both numbers--but I keep recieving a syntax error, and apparently I have a missing semicolon somewhere:

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
36
37
38
39
40
41
#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
#include <fstream>
using std::ifstream;
#include <cstdlib> 
#include <cmath>

int main()
{
   ifstream indata; 
   int c; 
   int f;
  indata.open("temps.txt"); 
   if(!indata) { 
      cerr << "Error: file could not be opened" << endl;
      exit(1);
   }


  indata >> c;
  
   while ( !indata.eof() ) { // keep reading until end-of-file
      cout << "The temperature in Celsius is: " << c << endl;
      indata >> c; // sets EOF flag if no value found

    for (int f = 9.0 / 5 * c + 32;){
          cout << "The temperature in Fahrenheit is: " << f << endl;




   }
  }

   indata.close();
   cout << "End-of-file reached.." << endl;
   return 0;
}
What does line 28 do?

Edit: You might also want to assign c a value before using it. More specifically, assign it data from your file before displaying it to the screen.
Last edited on
Topic archived. No new replies allowed.