 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rakesh Sinha Guest
|
Posted: Sat Dec 18, 2004 11:00 am Post subject: pos_type - How to define it ? |
|
|
Hello,
I am writing this application for which I need to determine the file
size.
My code looks roughly as follows.
#include <fstream>
#include <iostream>
using std::ifstream;
ifstream fp;
fp.open("myfile", ios::binary);
ifp.seekg(0, ios::end);
pos_type length = ifp.tellg();
//Process with length
std::cout << "Length of file " << length << std::endl;
My problem is where is pos_type defined ? I can make an approximation
like unsigned long instead of it to get around , but I would not like
to do that.
I referred to the C++ 2003 standards and here is what I had found it
then.
[lib.ios] 27.4.4
namespace std {
..
class basic_ios : public ios_base {
public:
// Types:
typedef typename traits::pos_type pos_type;
};
}
How would I use this type in my program ?
|
|
| Back to top |
|
 |
David Harmon Guest
|
Posted: Sat Dec 18, 2004 6:53 pm Post subject: Re: pos_type - How to define it ? |
|
|
On 18 Dec 2004 03:00:23 -0800 in comp.lang.c++, "Rakesh Sinha"
<rakesh_usenet (AT) yahoo (DOT) com> wrote,
| Quote: | ifp.seekg(0, ios::end);
pos_type length = ifp.tellg();
|
Should be:
ios::pos_type length = ifp.tellg();
or
std::ios::pos_type length = ifp.tellg();
|
|
| Back to top |
|
 |
Jonathan Turkanis Guest
|
Posted: Sat Dec 18, 2004 9:28 pm Post subject: Re: pos_type - How to define it ? |
|
|
David Harmon wrote:
| Quote: | On 18 Dec 2004 03:00:23 -0800 in comp.lang.c++, "Rakesh Sinha"
[email]rakesh_usenet (AT) yahoo (DOT) com[/email]> wrote,
ifp.seekg(0, ios::end);
pos_type length = ifp.tellg();
Should be:
ios::pos_type length = ifp.tellg();
or
std::ios::pos_type length = ifp.tellg();
|
Also note that pos_type (which is usually just std::streampos) is not an
integral type, but is convertible to one.
Jonathan
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|