CodePudding user response:
Don't put the whileCodePudding user response:
Can be placed inside the while, the fstream is a class, not return a value, while judging condition is in the judgment "& gt; & gt;" The return value of a function, "& gt; & gt;" Is a been overloaded operators, the overloaded function has a return value types of fstream& , the return value is usually input stream itself, if there is no input when you make a mistake or the end of the file (EOF), the input stream has been effectively jump out a while loop, met, after the end of the file EOF "& gt; & gt;" The return value of a function is zero, to the end of the while loop,CodePudding user response:
"& gt; & gt;" Is a been overloaded operators, is essentially function, your data [5000] is an array, the data is a pointer to the first address of the array, "& gt; & gt;" Operator can't array as operands, if you want to, you can write an overloaded function to make the "& gt; & gt;" Reload again once,CodePudding user response:
Can change like this: the int data [5000] to int data, or string data, these type "& gt; & gt;" Can accept, the running effect is as follows: