Trouble with I/O files again, this time its with 'Illegal characters
My code is:
and the errors are:Code:
cout << indexoffirst << " = "<< first << endl << endl;
cout << indexofsecond << " = " << second<< endl << endl;
cout << indexofthird << " = " << third << endl << endl;
cout << indexoffourth << " = " << fourth << endl <<endl;
ifstream c_file ( "D:\\LotteryPrograms\\Fla_Mega_Money\\Highest_Frequencies.txt" );
if (!c_file )
{
cout << "Can't open input file" << " Highest_Frequencies.txt " << endl << endl;
cin.get();
exit(1);
}
ofstream c_file ( "D:\\LotteryPrograms\\Fla_Mega_Money\\Highest_Frequencies.txt" );
if (! c_file )
{
cout << "Can't open input file " << endl << endl;
cin.get();
exit(1);
}
c_file >> indexoffirst >> " = " >> first;
c_file >> indexofsecond >> " = " >> second;
c_file >> indexofthird >> " = " >> third;
c_file >> indexoffourth >> " = " >> fourth;
Code:Error 1 error C2371: 'c_file' : redefinition; different basic types in line 164
Error 2 error C2088: '!' : illegal for class in line 166
Error 3 error C2088: '>>' : illegal for class in line 174
Error 4 error C2088: '>>' : illegal for class in line 175
Error 5 error C2088: '>>' : illegal for class in line 176
Error 6 error C2088: '>>' : illegal for class in line 177
When I looked up the errors, I got:
Code:Compiler Error C2071
'identifier' : illegal storage class
identifier was declared with an invalid storage class. The following sample generates C2071:
// C2071.cpp
struct C {
extern int i; // C2071, remove extern to resolve error
};
How and where did I use an 'extern'?
Why is '!' and '>>' illegal now and not before?Code:Compiler Error C2088
'operator' : illegal for 'class-key'
The operator was not defined for the structure or union. This error is only valid for C code.
The following sample generates C2088 three times:
// C2088.c
struct S
{
int m_i;
} s;
int main()
{
int i = s * 1; // C2088
struct S s2 = +s; // C2088
s++; // C2088
}
My question is, "Why these errors now and not before when I used the same code before? All I did was to change the file from b_file to c_file." . . . More importand, how do I correct the errors so I don't make them again?
Can somebody please explain my mistakes (hopefully in plain English so even a dummy like me can understand the answer)? . . . . therry