In this video, I did not understand why was the next number in the input data stream was considered after -1 as EOF has been reached(EOF=-1 and the while condition is until the data in the list equals EOF is reached, continue to read one input from the data stream)?. I mean to say how did the pointer move beyond -1 between the list, that is, at query points?
OR
How does compiler differentiate between the -1 used as query point and the -1 used as EOF?
Heaps Interview Q - Largest K Elements II - STL
Hello @CCCB0035,
EOF can have any negative value depending upon the compiler.
But, in most of the modern compilers it is set to -1.
Compiler set some properties/parameters with EOF to distinguish EOF from the negative numbers to avoid ambiguity. Moreover, these properties are compiler dependent.
Hope, this would help.
Give a like, if you are satisfied.