FileToC is a desktop utility designed for the byte-by-byte conversion of any file into a standard C/C++ array within a *.c file. When developing firmware for microcontrollers (MCUs), it is often necessary to embed raw binary or text files directly into the source code—for instance, when serving static Web interface assets (HTML, CSS) directly from the MCU’s flash memory.
In the main application window, you can enter the target file path manually or use the standard file selection dialog by clicking the “Browse” button.


Once a file is selected, its absolute path will be displayed in the text field. The path can also be edited manually if necessary.

To generate the C file, simply click the “Convert” button. The application will generate a new *.c file and display a message box confirming successful execution. For data integrity verification, this message box displays both the calculated total file size and the actual number of bytes processed by the byte counter during the copy operation.

Possible Error Messages:
- Failed to open the file for reading — occurs if the source file path or name is incorrect, or if the file is locked by another process;
- Failed to open the file for writing.
The conversion outputs a new file sharing the original filename but with a *.c extension. This generated file automatically includes stdint.h and declares two variables:
filename_fileSize= the exact file size in bytes;filename_FileData []= {the array containing the byte-by-byte hex data of the original file};.
Example:
Original main.cpp file:
//<br />
#include <windows.h><br />
.......<br />
.......<br />
.......<br />
return DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DlgMain);<br />
}
Generated main.c output:
/*******************<br />
The code generated by FileToC converter<br />
Developed by KVV_EL<br />
kvvel.com<br />
kvv_el@bk.ru<br />
*******************/</p>
<p>#include <stdint.h></p>
<p>uint32_t main_fileSize = 5732;</p>
<p>uint8_t main_FileData [] = {<br />
0x2F, 0x2F, 0x0D, 0x0A, 0x23, 0x69, 0x6E, 0x63, 0x6C, 0x75, 0x64, 0x65, 0x20, 0x3C, 0x77,<br />
0x69, 0x6E, 0x64, 0x6F, 0x77, 0x73, 0x2E, 0x68, 0x3E, 0x0D, 0x0A, 0x23, 0x69, 0x6E, 0x63,<br />
0x6C, 0x75, 0x64, 0x65, 0x20, 0x3C, 0x63, 0x6F, 0x6D, 0x6D, 0x63, 0x74, 0x72, 0x6C, 0x2E,<br />
......................<br />
......................<br />
......................<br />
0x4E, 0x29, 0x2C, 0x20, 0x4E, 0x55, 0x4C, 0x4C, 0x2C, 0x20, 0x28, 0x44, 0x4C, 0x47, 0x50,<br />
0x52, 0x4F, 0x43, 0x29, 0x44, 0x6C, 0x67, 0x4D, 0x61, 0x69, 0x6E, 0x29, 0x3B, 0x0D, 0x0A,<br />
0x7D, 0x0D, 0x0A<br />
};


