getting strange error PLEASE HELP

Pages: 12
You should try to read the error message. That part you posted is too short to see what is wrong.
it wont let me post the error message here because its too long but heres a bit more
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(726): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(764): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(811): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(937): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(944): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(951): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(958): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(968): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>,std::string>(std::basic_ostream<_Elem,_Traits> &&,_Ty)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ty=std::string
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(1085): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(186): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(192): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(199): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(206): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(226): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'

the whole error message looks like this
if i click on one of the messages it brings me into an istream and ostream header file that visual studios created. so i dont understand how there are errors in a file that visual studios created and i dont why its using that header file
Last edited on
does anyone know why this happens?
How about this?


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
#include <iostream>
#include <fstream>
using namespace std;

const int NUM_SCORES = 5;

typedef struct 
 {
	int day;
	int month;
	int year;
 } Date; 

typedef struct 
 {
	int id;
	string firstName;
	string surName;
	Date dob;
	float scores[NUM_SCORES];
 } Student;

typedef Student ItemType; 

ItemType aStudent;

int main()
{
	
	ifstream infile ("students.txt");		
		for (int i = 0; i < 5; i++)
		{
			infile >> aStudent.id >> aStudent.firstName >> aStudent.surName >> aStudent.dob.day >> aStudent.dob.month >> aStudent.dob.year
			   >> aStudent.scores[0] >> aStudent.scores[1] >> aStudent.scores[2] >> aStudent.scores[3]
			   >> aStudent.scores[4];
		}

		cout << "Id\tFirst name\tSurname\t\tDate\t\tScores\n"; 
	for (int i = 0; i < 5; i++)
		{
			cout << aStudent.id << "\t" << aStudent.firstName << "\t\t" << aStudent.surName << "\t\t" <<  aStudent.dob.day << "/" << aStudent.dob.month <<"/" << aStudent.dob.year 
			<< "\t\t" << aStudent.scores[0] << " " << aStudent.scores[1] << " " << aStudent.scores[2] << " " << aStudent.scores[3] << " "
			<< aStudent.scores[4] << endl;;
		}
	
	
	infile.close();	
	
	
	return 0;
}

no still getting strange error message
i tired writing the code a different way but i still get the same message
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
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;


const int NUM_SCORES=4;

typedef struct
{
int day;
int month;
int year;
} Date;

struct Student
{
int number;
string firstname;
string surname;
Date dob;
int scores[NUM_SCORES];
} ;


int _tmain(int argc, _TCHAR* argv[])
{
Student student[6];
ifstream infile ("student.txt");

while (!infile.eof())
{
for ( int i=0; i<6; i++)
{
infile>>student[i].number>>student[i].firstname>>student[i].surname>>student[i].dob.day>>student[i].dob.month>>student[i].dob.year>>student[i].scores[0]>>student[i].scores[1]>>student[i].scores[2]>>student[i].scores[3]/*>>student[i].scores[4]*/;

}
}
cout<<"The unsorted table is\n"<<endl;
cout<<"NUMBER\tNAME\tSURNAME\tDOB DD/MM/YYYY\t\t\t\tSCORES";
for (int i=0; i<6; i++)
{
cout<<endl<<student[i].number<<"\t"<<student[i].firstname<<"\t"<<student[i].surname<<"\t"<<student[i].dob.day<<"\t"<<student[i].dob.month<<"\t"<<student[i].dob.year<<"\t"<<student[i].scores[0]<<"\t"<<student[i].scores[1]<<"\t"<<student[i].scores[2]<<"\t"<<student[i].scores[3]/*<<"\t"<<student[i].scores[4]*/<<endl;
}

infile.close();
return 0;
}
Last edited on
Your compiler is broken
how do i fix it? i dont understand how it broke and when i try to compile the program on a different computer i get the same error. I tired rewriting the program from the start on a different computer and it still wont work yet it compiles other programs.
how is that possible?
Last edited on
its not broken i forgot to #include <string>
Topic archived. No new replies allowed.
Pages: 12