N
nimdez
Hi,
I am working on an existing code base in which a lot of data displayed
to the user is formatted in tables. Most tables are printed row-by-row
using printf() with "%[width]s" print conversion specification for
each column (e.g. printf(%10s %25s %15s\n", pszCol1, pszCol2,
pszCol3)). My problem is that when a string is longer the column's
width, it overflows the column and takes the table out of alignment.
What I want it to do is word-wrap within the column, thus keeping the
table aligned.
The most desirable solution for this is an extended printf() function,
which accepts another format-flag that specifies the field as
word-wrapping. For example (new format flag is '='):
xprintf("%=10s %=25s %=15s\n", pszCol1, pszCol2, pszCol3)
1. Can anyone point me to an implementation of such extended printf()?
2. If not, any other creative solutions are most welcome.
Thanks,
Rod
I am working on an existing code base in which a lot of data displayed
to the user is formatted in tables. Most tables are printed row-by-row
using printf() with "%[width]s" print conversion specification for
each column (e.g. printf(%10s %25s %15s\n", pszCol1, pszCol2,
pszCol3)). My problem is that when a string is longer the column's
width, it overflows the column and takes the table out of alignment.
What I want it to do is word-wrap within the column, thus keeping the
table aligned.
The most desirable solution for this is an extended printf() function,
which accepts another format-flag that specifies the field as
word-wrapping. For example (new format flag is '='):
xprintf("%=10s %=25s %=15s\n", pszCol1, pszCol2, pszCol3)
1. Can anyone point me to an implementation of such extended printf()?
2. If not, any other creative solutions are most welcome.
Thanks,
Rod