If you want to do this the C++ way, do it like this:
#include <fstream> #include <iterator> #include <algorithm> 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<char>(input), std::istreambuf_iterator<char>( ), std::ostreambuf_iterator<char>(output)); }
If you need that data in a buffer to modify it or something, do this:
#include <fstream> #include <iterator> #include <vector> int main() { std::ifstream input( "C:\\Final.gif", std::ios::binary ); // copies all data into buffer std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(input), {}); }
Related Posts:
- C++ string to double conversion
- What is difference between Application Buffer and System Buffer
- Why unsigned int 0xFFFFFFFF is equal to int -1?
- C++ – Decimal to binary converting
- C++ string to double conversion
- How to reverse an std::string? [duplicate]
- Fastest way to check if a file exist using standard C++/C++11,14,17/C?
- Fastest way to check if a file exist using standard C++/C++11,14,17/C?
- Reading from .txt file into two dimensional array in c++
- How can I get the list of files in a directory using C or C++?
- How can I get the list of files in a directory using C or C++?
- c++ Read from .csv file
- Reading string by char till end of line C/C++
- Fastest way to Convert String to Binary?
- Reading data from file into an array
- How to print (using cout) a number in binary form?
- How to Read from a Text File, Character by Character in C++
- How many spaces for tab character(\t)?
- How do I build a graphical user interface in C++? [closed]
- What are the differences between a pointer variable and a reference variable in C++?
- rand() between 0 and 1
- how to implement Interfaces in C++?
- What exactly is nullptr?
- How to make a SIMPLE C++ Makefile
- finding dll for “The specified module could not be found”
- no matching function for call to ‘ ‘
- Read file line by line using ifstream in C++
- Convert an int to ASCII character
- When should I write the keyword ‘inline’ for a function/method?
- Convert float to std::string in C++
- “items list” or “item list”
- When and why do I need to use cin.ignore() in C++?
- What does int & mean
- Evaluate a string with a switch in C++ [duplicate]
- “&” meaning after variable type
- How can I create objects while adding them into a vector?
- What is the printf format specifier for bool?
- libpng warning: iCCP: known incorrect sRGB profile
- In CLion, header only library: file “does not belong to any project target, code insight features might not work properly”
- Is a function definition not allowed here before a ‘{‘ token?
- Error at constructor : Expected an identifier?
- identifier “string” undefined?
- What does LPCWSTR stand for and how should it be handled with?
- A warning – comparison between signed and unsigned integer expressions
- How can I convert const char* to string and then back to char*?
- How do I call the class’s destructor?
- Can’t resolve Error: indirection requires pointer operand (‘int’ invalid)
- Defining a struct in flex error C++
- C++ Postfix calculator using stacks
- LNK1168: cannot open debug\file.exe for writing
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- error: request for member ‘..’ in ‘..’ which is of non-class type
- Socket API or library for C++?
- Initialize empty vector in structure – c++
- C++ catching all exceptions
- error: new types may not be defined in a return type
- error: passing ‘const …’ as ‘this’ argument of ‘…’ discards qualifiers
- Printing an array in C++?
- Resolve build errors due to circular dependency amongst classes
- error: “initializer expression list treated as compound expression”
- The compiler is complaining about my default parameters?
- read word by word from file in C++
- RPN Calculator for C++
- How do you make a HTTP request with C++?
- Error: C2228: left of ” must have class/struct/union
- error C2679: binary ‘<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
- Multi-character constant warnings
- Error: vector does not name a type
- How to convert ASCII value into char in C++?
- error C2601: ‘main’ : local function definitions are illegall – MS VS 2013 Compiler
- std::string length() and size() member functions
- How to convert QString to int?
- Update GCC on OSX
- Which is faster C++ String length() or size()?
- creating an array of structs in c++
- How to read lines of text from file and put them into an array
- Undefined reference to class constructor, including .cpp file fixes
- Learning to work with audio in C++
- Creating an instance of class
- sorting in std::map where key is a std::string
- System not declared in scope?
- no debugging symbols found when using gdb
- C++ Array of pointers: delete or delete []?
- ERROR: Control may reach end of non-void function /
- Function stoi not declared
- What’s the difference between while(cin) and while(cin >> num)
- Too many arguments to function
- not declared in this scope’ when using strlen()
- Converting a Cubemap into Equirectangular Panorama
- Negative RGB Values
- DEV C ++ Error: expected declaration before ‘}’ token
- “cannot be used as a function error”
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- Displaying contents of a vector container in C++
- Converting string to unsigned int returns the wrong result
- Visual c++ can’t open include file ‘iostream’
- c++ vector bubble sort
- compare and swap vs test and set
- Weighted random numbers
- compare and swap vs test and set