What's the syntax error for this cpp.

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
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
struct StudentType
{
	string FirstName[20];
	string LastName[20];
	string ID[20];

};

struct Grades
{
	int Quiz_1[20];
	int Quiz_2[20];
	int Quiz_3[20];
	int Quiz_4[20];
	int Quiz_5[20];
	int FirstExam[20];
	int SecondExam[20];
	int FinalExam[20];
	int Assign_1[20];
	int Assign_2[20];
	int Assign_3[20];
	int Assign_4[20];
	int Assign_5[20];
};


void main ()



{
	StudentType Student[20];
	Grades StdGrd[20];
	ifstream myFile;
	myFile.open("StudentsInfo.txt");
	for (int counter = 0 ; counter < 20 ; counter++)
		myFile >> Student[counter].ID >> Student[counter].FirstName >> Student[counter].LastName
		>> StdGrd[counter].FirstExam >> StdGrd[counter].SecondExam >> StdGrd[counter].FinalExam >>
		StdGrd[counter].Quiz_1 >> StdGrd[counter].Quiz_2 >> StdGrd[counter].Quiz_3 >> StdGrd[counter].Quiz_4 >>
		StdGrd[counter].Quiz_5 >> StdGrd[counter].Assign_1 >> StdGrd[counter].Assign_2 >> StdGrd[counter].Assign_3 >>
		StdGrd[counter].Assign_4 >> StdGrd[counter].Assign_5;
myFile.close();

}

Error line is: error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string [20]' (or there is no acceptable conversion).
Last edited on
You need code tags for that, and you should also stop using void main because void main is stupid.
What's code tag? D: Thanks in advance.

Edit: I've tried int main.
Same problem still persists >,<"
Last edited on
Search the forum.
And int main isn't going to solve your problem. It's just because void main is stupid beyond imaginable bounds.
Done.. My problem is stuck.. at myFile>>
try myFile>> Student[counter].ID[counter].c_str() ..for all the string parameters i think this will work .
or you can use only myFile>> Student[counter].ID[counter] ..for all the string parameter type .
Topic archived. No new replies allowed.