An ePub file is just a .zip file containing (x)html along with associated images, fonts, and xml files containing metadata and a table of contents. See the
Step by Step guide to ePub creation for links to learning more about the spec.
I don't know much about C, but I'm sure there are ways to use it to create xml and zip files, and if it can do that, it can create epubs.