Advertisement

Opening files

Started by November 17, 1999 08:28 PM
3 comments, last by Slayer-X 25 years, 1 month ago
I just use good old DOS fopen.

------------------
- mallen22@concentric.net
- http://members.tripod.com/mxf_entertainment/

I use either ifstream and ofstream or fopen.

------------------

Advertisement
fopen and fscanf / fprintf for reading and writing.
I'm just wondering how most of you open files, I know how I just want to see what the fastest and most common way is.
If you're using Windows and you want speed the Win32 API functions CreateFile, ReadFile, WriteFile should be fastest. All the other options (fopen/istream/whatever) call on the services of these functions at some point. The only thing to watch is that they aren't buffered. So if you make lots of short reads or writes it will go SLOOOOOWWWWWW!

If I want speed and buffering, I use CreateFileMapping and MapViewOfFile. These allocate a file into the process's address space so you can access it through a pointer. Its kind if like turning the file into a second swapfile.

This topic is closed to new replies.

Advertisement