notes/GCC C code to embed text files in a program-rG8Mj4Wf.sh
//More examples - https://github.com/metalx1000/C-Code-with-embedded-files
/*
* Copyright (c) 2017 Kris Occhipint.
* http://filmsbykris.com
*
* Embed text files in a C program
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
//create object file -- architecture may very
//objcopy --input binary --output elf64-x86-64 --binary-architecture i386 file.txt file.o
//compile: gcc textfile_3_obj.c file.o -o textfile_3_obj
//for windows/mingw remove underscores
extern char _binary_file_txt_start;
extern char _binary_file_txt_end;
int main(){
char* p = &_binary_file_txt_start;
while ( p != &_binary_file_txt_end ) putchar(*p++);
return 0;
}