Hi,
I want to be able to use std stream objects to manipulate files, but some of the files are too big. I want to be able to do the folowing:

>int64_t fileSize;
>strm.seekg(0,ios::end);
>fileSize = static_cast<int64_t>(strm.tellg());
>cout<<"File size is "<<fileSize;

This code will output -1 if the size of the file is too large to fit into an int type.

The reason I am type casting is that tellg() and other related stream functions return the streampos type. My problem is that the streampos type, which is equivalent to an int, is not big enough to contain the size of my file types. I need the int64_t for that.

thanks.

Qucik correction, stream pos is equivalent to long, not int

Jon jon

It might be compiler dependent, but VC++ 2008 Express will accept a 64-bit integer as the first parameter to seekg() which I guess means it supports huge files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.