I have no clue whats wrong

I am getting these errors why?

Severity Code Description Project File Line Suppression State
Error C2679 binary '>>': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) Project2 c:\users\nchun\source\repos\project2\project2\source.cpp 26

and syntax error "missing ';' before 'return'

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  #include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std; 

int main()
{
	ifstream datain; 

	double grade, max = -999, WholeMax = -999;
	int count = 0, wholecnt = 0;
	double total = 0.0, avg = 0.0, wholeTotal = 0.0, wholeAvg = 0.0;
	string fname, lname;

	std::cout << std::setprecision(1) << std::fixed;

	datain.open("Lab5data.txt");

	if (datain.fail())
	{
		cout << "**File not found**";
		return 1;
	}
	else
	{
		while (datain >> fname >> lname)
		{
			total = 0;
			avg = 0;
			count = 0;
			max = -999;
			while (datain >> grade && grade != -1)
			{
				total += grade;
				wholeTotal += grade;
				if (max < grade)
				{
					max = grade;
				}
				if (WholeMax < grade)
				{
					WholeMax = grade;
				}

				count++;
				wholecnt++;
			}
			cout << "The average for" << fname << "" << lname << "is:" << total / count;
			cout << "and the highest grade is" << max << endl;
		}

		// Closing the Input file
		datain.close();

			 return 0;
	} 

		}
If that is indeed your source code without any changes Visual Studio 2017 compiles it without even a warning.

Without having a copy of your datafile, or even an idea of what is in the file, I can't test if the code actually runs.
Topic archived. No new replies allowed.