Why is vertical tab (\v) not working?

Basically i want to output this
1 21 41 61 81
2 22 42 62 82
3 23 43 63 83
4 24 44 64 84
5 25 45 65 85
6 26 46 66 86
7 27 47 67 87
8 28 48 68 88
9 29 49 69 89
10 30 50 70 90
11 31 51 71 91
12 32 52 72 92
13 33 53 73 92
14 34 54 74 93
15 35 55 75 94
16 36 56 76 95
17 37 57 77 96
18 38 58 78 97
19 39 59 79 98
20 40 60 80 99

This is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
  #include <stdio.h>
int main(void)
{
	int i;
	for (i = 1; i < 100; i++)
	{
	   printf ("%d\v", i);
	   if (i % 20 == 0)
	   printf("\n");
	}
	return 0;
}

However it does nothing. I get only ♂ signs.
Last edited on
Because your run-time environment does not support it.
Even if it did, how would you get back to the top line to display the second column?
What do you suggest?
Create a two dimemsional array.
Populate it column by column, then print it row by row.
@Gondvanaz

Or
1
2
3
4
5
for (i = 1; i < 21; i++)
	{
	   printf ("%d  %d  %d  %d  %d \n", i, i+20, i+40, i+60, i+80);
	 }
printf("\n");
Well after all i wrote down this. I wish i have done it with the vertical tab \v but still... it does the job.
Thanks for the suggestion, AbstractionAnon, but i didn't learn the arrays yet.
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
int main(void)
{
	int i, num;
	for (num = 1; num <= 20; num++)
	{
		for (i = num; i < 101; i = i + 20)
			printf("%d\t", i);
		printf("\n");
	}
	return 0;
}

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.
Topic archived. No new replies allowed.