Reading and writing binary file

前端 未结 7 665
挽巷
挽巷 2020-11-22 16:29

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

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 17:02

    Here is a short example, the C++ way using rdbuf. I got this from the web. I can't find my original source on this:

    #include 
    #include 
    
    int main () 
    {
      std::ifstream f1 ("C:\\me.txt",std::fstream::binary);
    
      std::ofstream f2 ("C:\\me2.doc",std::fstream::trunc|std::fstream::binary);
    
      f2<

提交回复
热议问题