473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 ?

Jul 22 '05 #1
2 5486
On 18 Dec 2004 03:00:23 -0800 in comp.lang.c++, "Rakesh Sinha"
<ra***********@yahoo.com> 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();

Jul 22 '05 #2
David Harmon wrote:
On 18 Dec 2004 03:00:23 -0800 in comp.lang.c++, "Rakesh Sinha"
<ra***********@yahoo.com> 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
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alex J. Dam | last post by:
Hi, which guidelines should be used about those integer types defined in the C++ Standard Library, like string::size_type, istream::pos_type, etc.? Are they meant to be used only in the library...
18
by: Bryan Parkoff | last post by:
"#define" can only be inside the global scope before main() function. "#if" can be tested after "#define" is executed. The problem is that "#define" can't be inside main() function. I do not wish...
2
by: Andreas | last post by:
Hi! I'm using an IplImage library from camellia.sourceforge.net, and the testbench calls a file only containing code like the one below. In cam_morphomaths_code.c the real computation is made,...
3
by: theotyflos | last post by:
Hi all, I have the following: /*--- SNIP ---*/ typedef struct Argument_s { char *address; int type;
9
by: pozz | last post by:
Hi all, I have the below #defines #define NUMBER1 30 #define NUMBER2 50 #define SUM (NUMBER1+NUMBER2) #define STRING1 "Byte: \x30" #define STRING2 "Byte: \x50"...
34
by: BQ | last post by:
Hello Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is greater than 35, it returns 56, if not, 20. I would like that at compile time, not at run time. ...
71
by: David T. Ashley | last post by:
Where is the best place to define TRUE and FALSE? Are they in any of the standard include files, ever? Do any standards apply? What I've traditionally done is something like: #ifndef...
23
by: anon.asdf | last post by:
Hello! In the following code-snippet, is it possible to initialize each element of arr, with STRUCT_INIT? struct mystruct { int a; char b; };
2
by: badc0de | last post by:
Hello.. a header file of one of my project has macro definitions like this (for example) #define PART_A_SORT_1_LABEL_STRING1 100 #define PART_A_SORT_1_LABEL_STRING2 200 #define...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.