C to HTML

This program translates one or more C source files into a well-formed, valid XHTML1.0 document. It was used to create amost of the C program listings on this site.

The program works in the following way:

The program will currently only correctly translate C89 source files, and does not support any additional keywords, library functions or preprocessing directives from the new C99 standard, although C++ style single line comments are supported.

Programming Issues

String handling like this is fairly complex in C, and most of the issues involved revolve around this. The following are the most significant:

Usage

Use the following syntax:

ctohtml file1.c file2.c file3.c > output.html

Source and Downloads