Thread: How to embed a file in a C program

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    204

    How to embed a file in a C program

    I have a C program. Within it, I would like to embed either a file or a pre-assigned variable. I would prefer a method that is platform independent.

    I am using the data type "RSA" from <openssl/rsa.h>. I have a key file in PEM format, but I would like to embed an RSA object in the program instead. I tried creating a char array and then casting the pointer, but that caused some sort of illegal casting issue. I tried using memcpy but I haven't been able to get it working that way. What is the best way of going about this? Is it possible to read a file directly from a memory buffer?

  2. #2
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Write a quick & dirty utility to read the PEM file into memory and output a C (source code) array

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do you embed data into a literal string ?
    By RingingSailor in forum C Programming
    Replies: 2
    Last Post: 12-20-2010, 10:12 AM
  2. Best way to embed data in source code?
    By monk64 in forum C Programming
    Replies: 3
    Last Post: 04-22-2010, 04:04 PM
  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. Embed browser dont receives mouse "click" events
    By aniquilator in forum Windows Programming
    Replies: 2
    Last Post: 01-25-2010, 07:41 AM
  5. How To Embed Data In Program While Compile?
    By ooosawaddee3 in forum C++ Programming
    Replies: 1
    Last Post: 09-09-2002, 10:14 AM