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
  • 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