I\'m trying to write code to read a binary file into a buffer, then write the buffer to another file. I have the following code, but the buffer only stores a couple of ASCI
If you want to do this the C++ way, do it like this:
#include
#include
#include
int main()
{
std::ifstream input( "C:\\Final.gif", std::ios::binary );
std::ofstream output( "C:\\myfile.gif", std::ios::binary );
std::copy(
std::istreambuf_iterator(input),
std::istreambuf_iterator( ),
std::ostreambuf_iterator(output));
}
If you need that data in a buffer to modify it or something, do this:
#include
#include
#include
int main()
{
std::ifstream input( "C:\\Final.gif", std::ios::binary );
// copies all data into buffer
std::vector buffer(std::istreambuf_iterator(input), {});
}