Q What is the return type of tellg ()?
A The return type istream::tellg() is streampos . Check out std :: istream :: tellg .
Q How to compare tellg () with unsigned long long int?
A Return value tellg() is an integral type. So you can use regular operators to compare two int s. However, you should not do this in order to draw any conclusions from them. The only operations that the standard claims to support are:
Two objects of this type can be compared with the operators == and! =. They can also be subtracted, giving a streamoff value.
Check std :: streampos .
Q Is it possible that the return type tellg () has a maximum value (from numeric_limits) that is less than unsigned long long int?
A The standard does not purport to support or disprove it. This may be true on one platform, while false on another.
Additional Information
Comparison of streampos , examples of supported and unsupported comparison operations
ifstream if(myinputfile); // Do stuff. streampos pos1 = if.tellg(); // Do more stuff streampos pos2 = if.tellg(); if ( pos1 == pos2 ) // Supported { // Do some more stuff. } if ( pos1 != pos2 ) // Supported { // Do some more stuff. } if ( pos1 != pos2 ) // Supported { // Do some more stuff. } if ( pos1 == 0 ) // supported { // Do some more stuff. } if ( pos1 != 0) // supported { // Do some more stuff. } if ( pos1 <= pos2 ) // NOT supported { // Do some more stuff. } int k = 1200; if ( k == pos1 ) // NOT supported { }
R sahu
source share