Mark Atwood (fallenpegasus) wrote,
Mark Atwood
fallenpegasus

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: geek, mysql
Subscribe

  • Mark Atwood speaking at Ignite OSCON 2010

    Mark Atwood speaking at Ignite OSCON 2010 Originally uploaded by O'Reilly Conferences This entry was originally posted at…

  • At LCA2010

    Wellington, January 2010, originally uploaded by datacharmer. Giuseppe caught me when I looked focused and concerned about something. I have…

  • At the Drizzle Developers Conference

    The Drizzle Developers, hard at work DSC_0129, originally uploaded by krow. The Drizzle Developers, hard at work, thinking about Burning…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments