Download

print

A generic printer for C

  • C
Code 208 linesC 204Dotfile 2Makefile 2
Docs 126 wordsMarkdown 126
NameModifiedLinesSize
.gitignore 2 lines<1% of this folder's lines 11 B<1% of this folder's bytes
Makefile 2 lines<1% of this folder's lines 59 B<1% of this folder's bytes
README.md 31 lines12% of this folder's lines 859 B10% of this folder's bytes
gcprint.h 46 lines17% of this folder's lines 1.4 KiB17% of this folder's bytes
print.c 15 lines6% of this folder's lines 388 B5% of this folder's bytes
print.h 168 lines64% of this folder's lines 5.5 KiB67% of this folder's bytes

README.md

print - a simple C printing library

This project is a single-file header that defines some functions to make it easy to do formatted text without using printf style specifiers. For example:

int x = 42;
print("My number is ", x, " and that's ", hex(x), " in hex");

API

print(...) // print text with a trailing newline
print_inline(...) // print text without a trailing newline

fprint(file, ...) // print text to a file with a trailing newline
fprint_inline(file, ...) // print text to a file without a trailing newline

If you put #define PRINT_COLOR 1 before the import, text will be printed with terminal colors.

Allocating strings

Additionally, if you are using the Boehm Garbage Collector, you can use #include "gcprint.h" to print to an allocated string.

char *s = String(...); // return an allocated string