Sunday 15 September 2013

C++ read the whole file in buffer

C++ read the whole file in buffer

What is a good approach to read the whole file content in a buffer for
C++? While in plain C I could use fopen(), fseek(), fread() function
combination and read the whole file to a buffer, is it still a good idea
to use the same for C++? If yes, then how could I use RAII approach while
opening, allocating memory for buffer, reading and reading file content to
buffer. Should I create some wrapper class for buffer which, deallocates
memory, allocated for buffer, in it's destructor, and the same wrapper for
file handling?

No comments:

Post a Comment