You are viewing fallenpegasus

entries friends calendar profile My Website Previous Previous Next Next
Mark Atwood - Something I wish that C style printf format strings could do
fallenpegasus
fallenpegasus
Add to Memories
Share
Something I wish that C style printf format strings could do
I wish I could say
	printf("%*.16xs", n, p);


where n is a size_t and p is a void*, and it would output n bytes as hex.


And I want to be able to say
	printf("%*qs", n, p);


and it would output n bytes as a C-style backslash quoted string.


Yes, I can write functions that do all this, but I have to worry about buffers, allocate buffer space, and so forth. Plus its a lot of noise and clutter, for just outputing potentially unprintable strings, often just for logging and debugging.

Tags: ,
Current Location: University of Tasmania, Hobart, Tasmania, Australia

Comments
dossy From: dossy Date: January 19th, 2009 10:34 pm (UTC) (Link)
Heh, you'd think by now that some kind of "Log4C" library (like Log4J) would be ubiquitous with these kind of utility functions in it.
fallenpegasus From: fallenpegasus Date: January 20th, 2009 01:28 am (UTC) (Link)
There is one for C++, which I need to learn because HyperTable uses it.
2 comments or Leave a comment
profile
Mark Atwood
Name: Mark Atwood
Website: My Website
calendar
Back May 2014
123
45678910
11121314151617
18192021222324
25262728293031
page summary
tags