Vertical tab doesn't do what you think it does.
As with most control characters, VT was designed to instruct printers to perform a specific function. (Said printers are now dinosaurs.)
VT has since been co-opted for various other purposes, none of which are relevant to your task.
The terminal has
always been a line-oriented device. Some, like the now famous and venerable VT-100 series, allow you to perform a variety of other operations on it, such as moving the cursor to a specific line and column, etc. But the full-screen terminal idea was most firmly cemented in the public's mind when the IBM-PC mapped video memory into the host address space -- which user programs could then manipulate directly.
These days, that's still a whole other can of worms. From your C++ program's perspective, standard I/O are still line-oriented devices and must be used as such.
It is not uncommon for you to have to generate pre-output data in order to format it properly. Here's an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <stdio.h>
#include <string.h>
int main()
{
int i;
char lines[20][17] // 20 lines, each a mazimum of 16 printable characters
= { { '\0' } }; // ...all initialized to zeros
// Fill the lines with data
for (i = 1; i <= 100; i++)
{
sprintf(
strchr( lines[(i+19)%20], '\0' ), // (index and print to the end of the line)
"%2d ", i ); // (print our formatted number)
}
// Print the lines to standard ouput
for (i = 0; i < 20; i++)
puts( lines[i] );
return 0;
}
|
Hope this helps.