Indentation (and wrap-indentation) of debug strings output by printf()/fprintf() in C program

Posted by mbaitoff on Stack Overflow See other posts from Stack Overflow or by mbaitoff
Published on 2011-01-08T08:44:22Z Indexed on 2011/01/08 8:54 UTC
Read the original article Hit count: 436

Filed under:
|
|
|

I'm using a debug output using printf() in my functions, but the output goes to the console starting at the 1st columns. I'd like to distinguish the nesting level of functions by indenting their output strings each time I dive into the function (it's implemented easily having a static int indentlevel; variable, which is incremented at the beginning of a function, used as a space-filler-count and decremented at the end). But the flaw is that once the output line becomes too long to be wrapped at the console edge, lines' wrapped parts start at column 1 of the console. Should I take care about this, since once the output is redirected to a file, lines are, say, one-line-length, and widths of the lines depend only on the text file viewer settings?

© Stack Overflow or respective owner

Related posts about c

    Related posts about string