Home > Back-end >  File feof function
File feof function

Time:09-16

Execution of the CNT=1 after the code, and I hope to make CNT=0, because for the first time, read documents, inside is empty, why want to ask next, how should be changed to make CNT=0

CodePudding user response:

You remove the if finally the semicolon

CodePudding user response:

reference 1st floor qybao response:
you removed the if finally the semicolon

And that have what relation

CodePudding user response:

refer to the second floor small chestnut you reply:
Quote: refer to 1st floor qybao response:
you removed the if finally the semicolon

With that have what relation
; On behalf of the end of the statement, if you also is the use? Perform cnt++

CodePudding user response:

refer to fish out of water reply: 3/f
Quote: refer to the second floor you little chestnut reply:
Quote: refer to 1st floor qybao response:
you removed the if finally the semicolon

With that have what relation
; On behalf of the end of the statement, if you also is the use? All cnt++ how

If this is within a function, if performs, output failed to open the file, return to the main function, cnt++ won't execute.

CodePudding user response:

references 4 floor you little chestnut response:
Quote: refer to the third floor the fish out of water reply:
Quote: refer to the second floor you little chestnut reply:
Quote: refer to 1st floor qybao response:
you removed the if finally the semicolon

With that have what relation
; On behalf of the end of the statement, if you also is the use? All cnt++ how

If this is within a function, if performs, output failed to open the file, return to the main function, cnt++ won't execute.
you read an empty file, while is sure to execute, the if and not stand, because you added a semicolon, cnt++ executes, it is not 1,
As to why the while performing, the reason is that for an empty file, when the program to open it, it's the cursor will stop at the beginning of the file, but because they did not save file what content (but EOF exists), namely the entire file storage a EOF, when a program to open the file, and directly call feof (), this function will stand in the position of the cursor back over its shoulder, and the result is saw the EOF, then returns 0, of course,
No matter how you are not the semicolon, logic is not right,
Really want to determine whether to end, while reading, loop determine whether to end,

CodePudding user response:

Ok, thanks brother
  • Related