Home > Back-end >  Why header file with the <fstream>, the program is unable to identify Cerr
Why header file with the <fstream>, the program is unable to identify Cerr

Time:09-18

# include & lt; Fstream>
using namespace std;
Void save_to_file ()
{
Ofstream outfile (" f1. Dat ");
if(! Outfile)
{
Cerr<" The open f1. Dat error "& lt; exit(1);
}
Int a, [10].
Cout<" Enter 10 integer Numbers: "& lt; for(int i=0; I<10; I++)
{
Cin> A, [I].
OutfileOutfile_close ();

Ofstream outfile (" f2. Dat ");
if(! Outfile)
{
Cout<" The open f2. Dat error ";
exit(1);
}
for(int i=0; I<10; I++)
{
Outfile
Outfile. Close ();

}
Void get_f2 ()
{
Ifstream. Outfile (" f2. Dat ", the ios: : app);
Ofstream. Outfile (" f1. Dat ", the ios: : out);
For (int I=5; I<10; I++)
{
Infile}
for(i=0; I<10; I++)
{
Outfile
}
Infile. Close ();
Outfile. Close ();
}
Int main ()
{
Save_to_file ();
Get_f2 ();
return 0;
}



The error C2065: '_cerr: undeclared identifier
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (8) : error C2297: '& lt; <': illegal, right operand has the type' char [18] '
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (12) : error C2065: 'cout, undeclared identifier
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (12) : error C2297: '& lt; <': illegal, right operand has the type' char [27] '
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (15) : error C2065: 'cin: undeclared identifier
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (15) : warning C4552: '& gt;> ': the operator has no effect; Expected operator with side - effect
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (17) : error C2065: 'outfile_close: undeclared identifier
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (19) : error C2086: 'outfile: redefinition
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (22) : error C2297: '& lt; <': illegal, right operand has the type' char [18] '
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (25) : error C2374: 'I' : redefinition. Multiple initialization
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (13) : see declaration of 'I'
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (33) : error C2143: syntax error: missing '; 'before'. '
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (33) : error C2143: syntax error: missing '; 'before'. '
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (34) : error C2143: syntax error: missing '; 'before'. '
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (34) : error C2143: syntax error: missing '; 'before'. '
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (37) : error C2065: 'infile' : undeclared identifier
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (37) : error C2065: 'a' : undeclared identifier
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (37) : error C2109: subscript requires an array or pointer type
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (37) : warning C4552: '& lt; <': the operator has no effect; Expected operator with side - effect
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (41) : error C2065: 'outfile: undeclared identifier
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (41) : error C2109: subscript requires an array or pointer type
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (41) : error C2563: mismatch in formal parameter list
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (41) : error C2568: '& lt; <': unable to resolve the function overload
Could be 'class STD: : basic_ostream & lt; Unsigned short, struct STD: : char_traits & lt; Unsigned short> & __cdecl STD: : endl (class STD: : basic_ostream & lt; Unsigned short, struct STD: : char_traits & lt; Unsigned short> & amp;) '
D: \ Microsoft visual studio \ vc98 \ include \ ostream (377) : see declaration of 'endl
Or 'class STD: : basic_ostream & lt; Char, struct STD: : char_traits & lt; char> & __cdecl STD: : endl (class STD: : basic_ostream & lt; Char, struct STD: : char_traits & lt; char> & amp;) '
D: \ Microsoft visual studio \ vc98 \ include \ ostream (372) : see declaration of 'endl
Or 'class STD: : basic_ostream & lt; _E, _Tr & gt; & __cdecl STD: : endl (class STD: : basic_ostream & lt; _E, _Tr & gt; & amp;) '
D: \ Microsoft visual studio \ vc98 \ include \ ostream (367) : see declaration of 'endl
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (43) : error C2228: left of 'close' must have a class/struct/union type
C: \ Users \ Administration \ Documents \ \ \ 6.1 C + + 2. CPP (44) : error C2228: left of 'close' must have a class/struct/union type

CodePudding user response:

# include & lt; Iostream>

CodePudding user response:

# include & lt; Bits/stdc++. H> !!!!!!!!!
  • Related