printf'ing a matrix
- by Flavius
I'm trying to implement an all-purpose function for printing 2D data. What I've come up with is:
int mprintf(FILE* f, char* fmt, void** data, size_t cols, size_t rows)
The challenge is determining how many bits to read at once from data, based on fmt.
The format fmt is going to be the stdlib's-specific format for printf() and alike.
Do you have any knowledge of already-existing features from stdlibc (GNU GCC C's) I could use to ease this up?
I try avoiding having to do it all manually, because I know "I am stupid" (I don't want to introduce stupid bugs). Thus, reusing code would be the bug-freest way.
Thanks
Addendum
I see there's a /usr/include/printf.h. Can't I use any of those functions to do it right and ease my job at the same time?