# include
# include
# include
# include
# include
# include
# include
# include
# include "shixun. H"
using namespace std;
//show the error part
Void chaxun ()//read information
{
char name[20];
Int grade=0;
Int num=0;
float score;
Ifstream in (" player. Dat ", the ios: : in);
If (==0) in
{
Cerr & lt; <"File open error! \n";
The exit (1);
}
Cout & lt; <"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" & lt;
Cout & lt;
I use VS2013 compiled tip
binary "==" : found no accept "STD: : ifstream" type of the left operand of the operator (or no acceptable conversion)
Ask everyone a great god, I am a c + + beginners
CodePudding user response:
Direct the if (! In)CodePudding user response:
If (0==) inCodePudding user response:
In==0 spelled wrong, in is variable?CodePudding user response:
if (! In){
Cerr & lt; <"File open error! \n";
The exit (1);
}
Or
if (! In)
{
Cerr & lt; <"File open error! \n";
return 0;
}
CodePudding user response:
Ifstream in (" player. Dat ", the ios: : in);If (in is_open ())
{
}
In is an instance, open the file stream, the most success, there seems to be not succeed there will be abnormal (to confirm) with is_open () method to confirm the flow has been opened.