What to use for file i/o in c++?

Started by
4 comments, last by alvaro 12 years, 7 months ago
In c++, what should one use for reading and writing to files?

It can be small text files or a huge 10gb file that stores mucho stuff (something like overly big minecraft world? Not sure if they use a single giant file or if its even possible)

Do people use the standard i/o thingy, stuff from the OS API or some external library?

Thanks

o3o

Advertisement
Hey friend,

you can use the istream library. Thats actually pretty easy to use. Here are some examples.

http://www.cplusplus...tutorial/files/

You can read textfiles, binary files etc. You can save whole structs in files and read them out easily.

What i also use very often is RandomAccess.

http://cplus.about.c...1/ss/random.htm

If u have more questions. Ask :-)

Bye

I open sourced my C++/iOS OpenGL 2D RPG engine :-)



See my blog: (Tutorials and GameDev)


[size=2]http://howtomakeitin....wordpress.com/

So i should just use the standard io library thingie? Oh and anyone know where can i find benchmarks and stuff on fixed point vs floating point? Google isnt helping much...

Cant benchmark myself because my computer is broken and i dont trust my code lol.

o3o


So i should just use the standard io library thingie? Oh and anyone know where can i find benchmarks and stuff on fixed point vs floating point? Google isnt helping much...


Yeah, stick with the standard library for file IO, if you can. If, for some reason, the standard library's file IO fail you, look into Boost's filesystem library. But yeah, stick with the standard library.

As for the fixed point vs floating point... you probably don't need to worry about that too much right now. Most processors have a unit that operates entirely in floating point arithmetic, so they're pretty dang fast. Are you sure you aren't trying to prematurely optimize this by fixed point vs floating point?

Cant benchmark myself because my computer is broken and i dont trust my code lol.

Trust your code. Profile it (but only in your actual game! profiling a simple test case of fixed vs floating point won't do you a whole lot of good). Start writing your game. If things start to run too slowly, profile *your* code, find the bottle neck, and fix it. Remember, it's *your* code that you're trying to make run fast enough, so it's going to have to be *your* code that you profile. But if it's running fast enough there's no sense in optimizing. And there's no sense in optimizing if you don't even have anything working and you don't know what you need to optimize.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Im not wanting to make a fixed point class because of performance but because its point doesnt float around xD Thats good for handling forces and such but not position :c

Ill propably end up using floats but i still want to make a fixed point class... Just interested in how they perform against floats, but cant find anything...

o3o

The very old wisdom (198x and 199x) is that integer operations are faster than floating-point operations because they require simpler circuitry . The slightly old wisdom (200x) is that floating-point operations are faster because there are better SIMD instructions to support them in modern processors. The eternal wisdom is that you should test it both ways and measure.

This topic is closed to new replies.

Advertisement