Error codes.

Hey guys, am currently being kept busy by a specific problem that has been so hard to solve. My question goes like this:
Make a design of an algorithm that can read dates and the temperatures values that is high and low, from a specific file do the average and display display it for the read date. You are required to write an program for the and the flow chart that is developed for this question. I don’t have any problem with the flow chart of the program, but I need an expert who can help me understand the error that I have always come across when trying to execute this program. C2676 - binary '>>': 'std::ostream' is the error code that am receiving in my outcome.
Below is the code that am using;.


#include <iostream>
#include<fstream>
#include <string>

using namespace std;


int main()
{

//varirable declaration
fstream file;
string word, filename;
string date;
double minTemperature;
double maxTemperature;
double avgTemperature;

//file name
filename = "file.txt";
//open file name
file.open(filename.c_str());

//open file word by word
while (file >> word)


cin >> "minTemperature = " >> minTemperature << endl;
{
date = word;

cin >> "maxTemperature = " >> maxTemperature << end;
}


//calculate Average temperature
avgTemperature = (minTemperature + maxTemperature) / 2;

//print results
cout >> " Date is "; >> date;
cout >> " Average temperature is "; >> avgTemperature;

return 0;
}
.
1
2
3
cin >> "minTemperature = " >> minTemperature << endl;
cin >> "maxTemperature = " >> maxTemperature << end;
}

You can't read into a const char*. Anything between "" is a const char*
You need to separate it into two different calls;
1
2
std::cout <<  "minTemperature = ";
std::cin >> minTemparature; 
> C2676 - binary '>>': 'std::ostream' is the error code that am receiving in my outcome.
clang wrote:
foo.cpp|28 col 9| error: invalid operands to binary expression ('std::istream' (aka 'basic_istream<char>') and 'const char [18]')
gcc wrote:
foo.cpp:28:9: error: no match for ‘operator>>’ in ‘std::cin >> "minTemperature = "’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘const char [18]’)

notice that it provides the line number where the error occurs (line 28)
and that the error message refers to istream >> const char [18]
¿why did you edit out those things?
Topic archived. No new replies allowed.