C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pos_type - How to define it ?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Rakesh Sinha
Guest





PostPosted: Sat Dec 18, 2004 11:00 am    Post subject: pos_type - How to define it ? Reply with quote



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





PostPosted: Sat Dec 18, 2004 6:53 pm    Post subject: Re: pos_type - How to define it ? Reply with quote



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





PostPosted: Sat Dec 18, 2004 9:28 pm    Post subject: Re: pos_type - How to define it ? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.