how to use fsetpos and fgetpos correctly

Onceler

Golden Member
Feb 28, 2008
1,262
0
71
I am trying to write a simple program in Code::Blocks GNU GCC in Windows 7 64 bit that will allow my program to determine the maximum number of bytes in a very large file say like 31 gigabytes and report that back.
So far what I have found through google is just prototypes which do not have any real world examples.
Can someone point me in the right direction or if I should be using fgetpos and fsetpos in the first place? Is there an easier way?
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I'm not sure I understand what you're trying to do. You can read the size of the file to the byte from the file system. On Win32 the api is FindFirstFile and FindNextFile. If you want a cross-platform solution try boost filesystem.
 

Onceler

Golden Member
Feb 28, 2008
1,262
0
71
Thank you
Anyone have anything that uses C and not C++? I really hate OOP.
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
Then you'll probably have to use platform specific APIs like FindFirstFile that was already mentioned.
 

Onceler

Golden Member
Feb 28, 2008
1,262
0
71
Which aspect of OOP is particularly disgusting to you?

The use of C++ does not mean being restricted to the OO paradigm.

The most compelling reason not to use OOP is that the filesizes tend to stay smaller and more readable.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
The most compelling reason not to use OOP is that the filesizes tend to stay smaller and more readable.

Are you talking about the source code? If so, that's the most inane reasons I've heard of for avoiding C++.

I can understand not wanting to learn a new language(it's not necessarily easy), but as a programmer learning a new language should be part of your skill set.
 

Onceler

Golden Member
Feb 28, 2008
1,262
0
71
no I am talking about the executables they don't run as fast as good old fashioned low level C
plus they are bigger
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
no I am talking about the executables they don't run as fast as good old fashioned low level C
plus they are bigger

Well that's even more ridiculous, unless you happen to running on some embedded system with severely limited resources.
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
no I am talking about the executables they don't run as fast as good old fashioned low level C
plus they are bigger

And you're writing what type of application where the tiny difference in speed and executable size makes a difference....?
 

Onceler

Golden Member
Feb 28, 2008
1,262
0
71
Look I just want to code in C, I don't want to use C++
it is a matter of preference maybe I will learn C++ eventually but for now I think I should stick to C
I had a programing class on C++ and that OOP really turned a knot in my gut.
I want to do the most basic things and worry about the higher level stuff later.
 
Last edited:

Merad

Platinum Member
May 31, 2010
2,586
19
81
Look I just want to code in C, I don't want to use C++
it is a matter of preference maybe I will learn C++ eventually but for now I think I should stick to C
I had a programing class on C++ and that OOP really turned a knot in my gut.
I want to do the most basic things and worry about the higher level stuff later.

I think once you learn it you'll find that OOP is significantly easy to use for projects with any real complexity than procedural programming.

But whatever. I think the root of the issue is that no one has even suggested any OOP solutions that I've seen. FindFirstFile is a C function and does not use OOP in any way.
 

Onceler

Golden Member
Feb 28, 2008
1,262
0
71
I do plan on learning C++ eventually but right now I just want to learn C so I can be experienced without skipping over important concepts