Table Formatter v0.1


Table Formatter is a small utility for pretty printing tabulated data in a table format. Data is added to the table programmatically when complete is printed to an output file in either CSV or pretty printed table format.

Rows are added to the table using a (mostly) subset of C printf style format specifiers:
s or SString of characters
c or CCharacter
d or iSigned decimal integer
uUnsigned decimal integer
oUnsigned octal integer
tTimestamp specified by a time_t value
x or XUnsigned hexadecimal integer
f, F, g or GDecimal floating point

[width].[precision] are also supported. Note that precision defaults to 0 so with floating point values it must always be specified or the value will be truncated to a whole number.


int main(int argc, char* argv[])
	struct table_t* table = table_init(stdout, "Test Table", 1);

	table_row(table, "%s%s", "Column 1", "Column 2");


	table_row(table, "%s%s", "String value", "test string");
	table_row(table, "%s%c", "Character value", 'c');
	table_row(table, "%s%d", "Signed integer", -1);
	table_row(table, "%s%u", "Unsigned integer", 42);
	table_row(table, "%s%o", "Octal integer", 511);
	table_row(table, "%s%8x", "Hexadecimal integer", 255);
	table_row(table, "%s%.5f", "Floating point", 3.14159);
	table_row(table, "%s%t", "Timestamp", 0);


	return 0;
Produces the following output:
$ ./table.exe 
| Test Table                                                    |
| Column 1            | Column 2                                |
| String value        | test string                             |
| Character value     | c                                       |
| Signed integer      | -1                                      |
| Unsigned integer    | 42                                      |
| Octal integer       | 0777                                    |
| Hexadecimal integer | 0x000000ff                              |
| Floating point      | 3.14159                                 |
| Timestamp           | Thursday, January 01, 1970, 12:00:00 AM |


Table Formatter is free under the MIT license.




Send any comments/suggestions/bugs to (Remember to remove the dwarf!)