Thread: Instead of using resources to embed a file in another, help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    319

    Instead of using resources to embed a file in another, help

    Instead of using windows resources, i would like to embed file data in an array instead inside the application, when it comes to adding the new .h that was created i am presented with a big error list which i have attached to the post, thanks for reading

    Code:
    #include "stdafx.h"
    #include <Windows.h>
    #include <string>
    #include <fstream>
    #include <vector>
    #include <cstdint>
    #include <istream>
    #include <algorithm>    // std::copy
    #include <iterator>     // std::back_inserter
    #include <stdlib.h>
    
    using namespace std;
    
    int main(int, char* argv[])
    {
       std::ifstream i("texture.jpg", std::ios::binary);
       std::ofstream o("bytesHeader.h");
    
       
       std::vector<std::uint8_t> buff;
       std::copy(std::istreambuf_iterator<char>(i), std::istreambuf_iterator<char>(),
           std::back_inserter(buff));
        
       o << "const char charArray[] = {\n";
           
       for (size_t i=0; i<buff.size(); ++i)
       {
          o << "0x" << std::hex << buff[i];
          if (i % 21) o << "\n";
          if (i < buff.size() + 1) o << ",";
       }
       
       o << "};\n";
       
      // system("pause");
       o.close();
       i.close();
       return 0;
    }
    Code:
    #include "stdafx.h"
    #include <Windows.h>
    #include "bytesHeader.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	return 0;
    }
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to embed a file in a C program
    By thetinman in forum C Programming
    Replies: 1
    Last Post: 01-20-2014, 07:50 PM
  2. Loading Text File Resources
    By Brokenhope in forum Windows Programming
    Replies: 4
    Last Post: 10-11-2010, 04:32 AM
  3. Gtk Plug, Socket, embed one program into another.
    By arkashkin in forum Linux Programming
    Replies: 2
    Last Post: 03-27-2010, 01:01 AM
  4. Programmatically add resources to exe file
    By Devils Child in forum C# Programming
    Replies: 15
    Last Post: 12-06-2009, 01:22 PM
  5. Storing resources into a single file
    By LuckY in forum Game Programming
    Replies: 20
    Last Post: 08-14-2004, 11:28 PM